Вы находитесь на странице: 1из 5

1. 8GD class 4 SD cARD recommended..

unzip NOOBS software onto it from laptop(us


e SDFormatter if necessary)
2. Insert card in PI and power up
3.If your display remains blank, you should select the correct output mode for y
our
display by pressing one of the following number keys on your keyboard;
1. HDMI mode this is the default display mode.
2. HDMI safe mode select this mode if you are using the HDMI connector and canno
t see
anything on screen when the Pi has booted.
3. Composite PAL mode select either this mode or composite NTSC mode if you are
using
the composite RCA video connector
4. Composite NTSC mode
4.Choose required OS.. Install it and follow procedure
*****************************************************
ARDUINO IDE ON PI:
1.sudo apt-get update
2.sudo apt-get install arduino
3.if u want to use different serial port, then
sudo leafpad
In the text editor type:
KERNEL== ttyAMA0?,SYMLINK+= ttyS0? GROUP= dialout
KERNEL== ttyACM0?,SYMLINK+= ttyS1? GROUP= dialout
Then select File > Save As and type /etc/udev/rules.d/99-tty.rules
sudo reboot
*****************************************************
PROGRAMMING ARDUINO USING SPI:
1.ENABLING SPI PINS:
a)sudo nano /etc/modprobe.d/raspi-blacklist.conf
b)#blacklist spi-bcm2700 or 8 (# it)
c)sudo reboot
d)then type lsmod (you shud see that bcm thingy)
2.TESTING SPI PORT:
a)ls /dec/spidev*
u shud see the following: /dev/dpidev0.0 /dev/spidev0.1
3. SPI COMMUNICTION:
sudo apt-get install python-dev
Finally, it is time to install the python SPI wrapper needed for python to a
ccess the port.
mkdir python-spi
cd python-spi
wget https://raw.github.com/doceme/py-spidev/master/setup.py
wget https://raw.github.com/doceme/py-spidev/master/spidev_module.c
sudo python setup.py install
Program:import spidev
import time

spi = spidev.SpiDev()
spi.open(0,0)
while True:
resp = spi.xfer2([0x00])
print resp[0]
time.sleep(1)
4.INSTALLING THE AVRDUDE PACKAGE:
cd /tmp
wget http://project-downloads.drogon.net/gertboard/avrdude_5.10-4_armel.deb
sudo dpkg -i avrdude_5.10-4_armel.deb
sudo chmod 4755 /usr/bin/avrdude
(lets avrdude run spi without sudo)
+++http://project-downloads.drogon.net/gertboard/+++
cd /tmp
wget http://project-downloads.drogon.net/gertboard/setup.sh
chmod +x setup.sh
sudo ./setup.sh
cd /tmp
wget http://project-downloads.drogon.net/gertboard/boards.txt
wget http://project-downloads.drogon.net/gertboard/programmers.txt
cd /usr/share/arduino/hardware/arduino
sudo mv boards.txt board.txt.bak
sudo mv /tmp/boards.txt .
sudo mv programmers.txt programmers.txt.bak
sudo mv /tmp/programmers.txt
sudo reboot
avrsetup(important)+++
U can now program the Ardunio using ISP Programmer
******************----------------------------**************
SERIAL COMMUNICATION:
1.DISABLE GETTY:
/etc/inittab
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100(# it)
/boot/cmdline.txt
remove the line console=ttyAMA0,115200 kgdboc=ttyAMA0,115200(to prevent pi sendi
ng serial data when it switchs on)
sudo reboot
2.INSTALL MINICOM
sudo apt-getinstall minicom
minicom -b 9600 -o -D /dev/ttyAMA0 ( attach to serial terminal)
3.INSTALL PI-SERIAL:
sudo apt-get install python-serial
4.PROGRAM:
PI:
import serial
import string
rot13 = string.maketrans(
"ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz",

"NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm")
test=serial.Serial("/dev/ttyAMA0",9600)
test.open()
try:
while True:
line = test.readline(eol='\r')
test.write(string.translate(line, rot13))
except KeyboardInterrupt:
pass # do cleanup here
test.close()
OR
import serial
ser = serial.Serial('/dev/ttyAMA0', 9600, timeout=1)
ser.open()
ser.write("testing")
try:
while 1:
response = ser.readline()
print response
except KeyboardInterrupt:
ser.close()
ARDUINO:
void setup() {
Serial.begin(9600);
}
void loop() {
int incomingByte;
if(Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// echo
Serial.write(incomingByte);
}
**********************-------------------------**********************
WIRELESS COMMUNICATION:
1)AD-HOC NETWORK:
a)make a backup:sudo cp /etc/network/interfaces /etc/network/interfaces_backup
b)open network interfaces file: sudo nano /etc/network/interfaces
c)edit file:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet static

address 192.168.1.1
netmask 255.255.255.0
wireless-channel 1
wireless-essid RPiAdHocNetwork
wireless-mode ad-hoc
d)restart the wlan0 network:sudo ifdown wlan0
sudo ifup wlan0
e)configure PI as a DHCP server:
sudo apt-get update
sudo apt-get install dhcp3-server
/etc/dhcp/dhcpd.conf
(the file shud contain the following)
ddns-update-style interim;
default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.5 192.168.1.150;
}
e)try ssh: ssh -lpi 192.168.1.1
************
2)WIRELESS ACCESS POINT:
a)sudo nano /etc/network/interfaces
Place a # sign in front of all the lines which mention wlan0 and wpa, except for al
low hotplug wlan0 . Then add the following lines to the file:
iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0

(file shud hav these 4 lines, rest commented)

sudo reboot
b)DHCP SERVER:
sudo apt-get install isc-dhcp-server
sudo nano /etc/dhcp/dhcpd.conf
Add a # character in front of the option domain-name lines like this:
Remove the # sign in front of the authoritative; statement like this:
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;
at the bottom, add these:
subnet 192.168.42.0 netmask 255.255.255.0 {
range 192.168.42.10 192.168.42.50;
option broadcast-address 192.168.42.255;
option routers 192.168.42.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}

sudo nano /etc/default/isc-dhcp-server


Change INTERFACES="" to INTERFACES="wlan0"
sudo service isc-dhcp-server restart
c)INSTALLIN Accesspoint Daemon:
sudo apt-get install hostapd
sudo nano /etc/hostapd/hostapd.conf
add following lines:
interface=wlan0
driver=nl80211
#driver=rtl871xdrv
ssid=MyPi
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCM
sudo nano /etc/default/hostapd
Remove the # in front of DAEMON_CONF and alter the line to read:
DAEMON_CONF="/etc/hostapd/hostapd.conf"
d)CONFIGURE IP ROUTING:
Edit /etc/sysctl.conf to enable IP forwarding:
sudo nano /etc/sysctl.conf
Find the line which reads Uncomment the next line to enable packet forwarding for
IPv4 and uncomment the next line like this:
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
Run the following command to activate forwarding now:
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
Now turn the Pi into a router with the follow commands:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
And save the routing tables into the file /etc/iptables.ipv4.nat
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
Edit /etc/network/interfaces :
sudo nano /etc/network/interfaces
And add the following line to the end of the file. This line will restore the ro
uting table whenever the Pi is booted:
pre-up iptables-restore < /etc/iptables.ipv4.nat
*********************If you are not using the Adafruit wifi adapters, you may ha
ve to change the driver=rtl871xdrv to say driver=nl80211*******

Вам также может понравиться