Thursday 22 October 2015

PROGRAMMING AND UPLOADING ARDUINO SKETCH WITHOUT IDE

Arduino-mk package makes it simple to build and upload sketches on a Raspberry Pi without the bloated Arduino IDE.
Install the package:

sudo apt-get install arduino-mk
This will install all the required software and files.
Create a library area in your user home directory with a demo sketch in it:
mkdir ~/sketchbook
cd ~/sketchbook
ln -s /usr/share/arduino/Arduino.mk
mkdir blink
cd blink
sudo nano blink.ino

// Blink

void setup(void) {
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, LOW);
  delay(1000);
  digitalWrite(13, HIGH);
  delay(1000);
}
Save it.
Create the Makefile:
sudo nano Makefile
# board tag is very import put your board name and model no
BOARD_TAG = mega2560 
ARDUINO_PORT = /dev/ttyACM0
ARDUINO_DIR = /usr/share/arduino
include /usr/share/arduino/Arduino.mk
make
make upload
It will prepare the c and bit files and burn the memory on your Arduino. Watch your LED blinks.
Other commands to perform various tasks:
make – no upload
make upload – compile and upload
make clean – remove all our dependencies
make depends – update dependencies
make reset – reset the Arduino by tickling DTR on the serial port
make raw_upload – upload without first resetting
make show_boards – list all the boards defined in boards.txt (11431)

How to write program for arduino

1. Frist install arduino into your machine. After installation done open arduino IDE.

2. Create new file in arduino IDE. Let's we make blink program into arduino.

    // Blink program for arduino microcontroller

void setup(void) {
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, LOW);
  delay(1000);
  digitalWrite(13, HIGH);
  delay(1000);
}


3. Save file and connect your arduino micro controller with machine.

4. Select board Tools > Board > Select Arduino board

5. Upload program check IDE bottom it will show your program upload successfully or error in your program.

6. After complete it check your arduino board.

Friday 16 October 2015

how to check running application status into linux

Open your terminal and type following command:

example:- ps aux | grep node


How to run application on startup in raspbianpi

1. Setp first open your raspbianpi terminal and type sudo nano /etc/rc.local.

2. put your application loaction and put your start file location.

for example: let me start node server when system start

/usr/local/bin/node /home/bananapi/Descktop/demoApp/app.js



How to run application on startup in ubuntu

1. Step first create xyz.conf file into /etc/init/ and put your script.

example : let me start node server on start up

description "test job"

start on runlevel [2345]

exec node /path/of/your/file/script.js

2. Save this file.

3. now type command sudo service xyz start. Node server will start.

You can stop it with stop command and restart with restart command.

Thursday 15 October 2015

Problem: apt-get-repository Command is Missing


I was trying to install the latest version of git from the Ubuntu Git Maintainers Team and I needed to add a Personal Package Archive (PPA) to the Software Sources. But when I tried to do this, I got an error:
?
sudo: add-apt-repository: command not found

Solution: Install the software-properties-common Package

To get the add-apt-repository command, install the software-properties-common package. For my Ubuntu version (precise), I also had to install the python-software-properties package:
?
$ sudo apt-get install software-properties-common python-software-properties
Then then you add the PPA, update your sources, and upgrade your the package. In may case, I wanted to upgrade git, so I did the following:
?
$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt-get update
$ sudo apt-get install git
And boom — I was all set.

Wednesday 14 October 2015

Setting Up a Static IP Address for the Raspberry Pi

Boot into Raspian and log in (Username. pi, Password. raspberry), this will all be command line stuff, so no need to log in to the GUI if X isn’t started automatically.
Have a pen and paper at the ready! . . . 
First, we need to list the network interface we currently have available:
cat /etc/network/interfaces
Static IP 01
The line . . . . 
iface eth0 inet dhcp
Implies that we’re currently getting the IP address via DHCP, meaning it’s being dynamically registered by the router. This is what we need to change!

Gathering Network Information:

Fist of all we need to retrieve some information from our router and the Raspberry Pi. First we need to run the following command to retrieve the first part of the information.
ifconfig
StaticIP-02
This reveals your router information, the bit you want is after eth0 (the ethernet connection). . . .
eth0      Link encap:Ethernet  HWaddr b8:27:eb:cc:03:0e
               inet addr:10.0.0.111  Bcast:10.0.0.255  Mask:255.255.255.0
Write down the following information. . .
  • inet addr – 10.0.0.111 (Pi’s Current IP Address)
  • Bcast –  10.0.0.255 (The Broadcast IP Range)
  • Mask –  255.255.255.0 (Subnet Mask Address)
We need a little more information before we proceed, so run the following command.
netstat -nr
Static IP 03
We need:
  • ‘Gateway’ Address – 10.0.0.138
  • ‘Destination’ Address – 10.0.0.0

Editing Network Configuration:

We now need to plug this information into the Raspberry Pi’s network configuration file using a text editor. For this use the nano text editor as follows. . .
sudo nano /etc/network/interfaces
Static IP 04
Simply change the line that reads:
iface eth0 inet dhcp
to
iface eth0 inet static
Then directly below this line enter the following (Please Note. You will need your own addresses we gathered in Part B, more details below). . . . 
address 10.0.0.11
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
10.0.0.138
To clarify what each part means. . . . 
address – The address you want to give your Pi, this can be any IP in the network range, but it’s usually advisable to go higher rather than lower, or you could end up logging different devices to the same IP! I’ve selected 10.0.0.11, as address (denoted by ‘inet addr‘), but this can be any IP address from the range10.0.0.1 to 10.0.0.255.
netmask – The ‘Mask‘ address we wrote down earlier.
network – The router IP address, this is the ‘Destination‘ Address was found earlier. You can also grab this off your router, it will say on the side somewhere.
broadcast – The ‘Bcast‘ address we wrote down earlier. 
gateway – This is the ‘Gateway‘ address we found earlier.
Static IP 05
So, it should look something like the above, but with your values!
Note that in the above example I also set the Wi-Fi IP to the same as the Ethernet for simplicity as this Raspberry Pi runs my BrickPi Interface Board normally.
Remember to save before exit, CTRL+X (exit) then yes to save changes!

Check the New Static IP Configuration:

We will now need to reboot the Raspberry Pi for the changes to take effect. 
sudo reboot
Log back into the Raspberry Pi and run 
ifconfig
Your new Network Setting be should revealed.
Static IP 06
To double checks all is working as it should, ping your ‘Gateway‘ Address. . . 
ping 10.0.0.11 -c 10
(the -c 10 command simply denotes that you want to ping it 10 times, if you forget to add this, it will ping the address continuously. To stop it press CTRL+C)
Static IP 07