What is Raspberry Pi

The Raspberry Pi is based on the Broadcom BCM2835 system on a chip (SoC) which includes an ARM1176JZF-S 700 MHz processor, VideoCore IV GPU, and was originally shipped with 256 megabytes of RAM, later upgraded (Model B and Model B+) to 512 MB. The system has Secure Digital (SD) or MicroSD (Model A+ and B+) sockets for boot media and persistent storage.

About Raspbian OS

Raspbian is a free operating system based on Debian optimized for the Raspberry Pi hardware. An operating system is the set of basic programs and utilities that make your Raspberry Pi run. However, Raspbian provides more than a pure OS: it comes with over 35,000 packages, pre-compiled software bundled in a nice format for easy installation on your Raspberry Pi.

Fun with Raspberry Pi

Time to get creative with your computing -- here are our favourite fun things you can do with your Raspberry Pi.

MAKE RESOURCES

Resources. Free resources to teach, learn and make with Raspberry Pi. Teach. Schemes of work to teach with Raspberry Pi · Learn. Exercises to learn with.

Python (programming language)

Python is a widely used general-purpose, high-level programming language.Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C++ or Java.The language provides constructs intended to enable clear programs on both a small and large scale.

RASPBERRY PI

The Raspberry Pi is a credit card-sized single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools. Tools available are Python as the main programming language, with support for C, C++, Java, Perl and Ruby.

Friday 5 December 2014

User Desired LED Blinking

STEP 1:

Open LX-Terminal.

Create a file with .py extension

Ex: nano userinput.py

Nano is a type of editor used to write the code in that file named userinput.

Type the following code in that file by insert key or by typing letter I on keyboard.

STEP 2:

Program:

#! /usr/bin/python
Import os
Import time
Import RPi.GPIO as GPIO
GPIO.setmode (GPIO.BCM)
GPIO.setwarnings (False)
GPIO.setup (17, GPIO.OUT)          //configuring 17th pin as output
GPIO.setup (27, GPIO.OUT)          // configuring 27th pin as output
#Setup variables for user input
led_choice = 0
count = 0
os.system (‘clear’)
print “which LED would you like to blink”
print “1: Red?”
print “2: Blue?”
led_choice = input (“choose your option: “)               //user choice
if led_choice  == 1:                                                       // select led to blink
os.system (‘clear’)
                    print  “You picked the Red LED”
                    count = input (“How many times would you like it to blink? :  ”)                                                                                                                         //user enter purpose
                    while count > 0 :
                                       GPIO.output (27, GPIO.HIGH)
                                       time.sleep (1)                         //to sleep for one second
                                       GPIO.output (27, GPIO.LOW)
                                      time.sleep (1)                        // to sleep for one second
                                      count = count-1
if led_choice == 2:                                                    // select led to blink
                   os.system (‘clear’)
                   print ”You picked the Blue LED”
                   count = input (“How many times would you like to blink? :  ”) //user enter purpose
                   while count  > 0 :
                                      GPIO.output (17, GPIO.HIGH)
                                      time.sleep (1)                    // to sleep for one second
                                      GPIO.output (17, GPIO.LOW)
                                      Time.sleep (1)                  // to sleep for one second        
                                      count = count-1

Save the file by typing  :wq and then press enter.

To check the output:Type python userinput.py

Output 1:


Output 2:


Output 3:


Output 4:

Program to blink LED

STEP 1:

Open LXTerminal.

Create a file with .py extension

Ex: nano example.py

Nano is a type of editor used to write the code in that file named example.

Type the following code in that file by insert key or by typing letter I on keyboard.

Program:

#! /usr/bin/python
Import time                                         //importing library called time
Import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup (17, GPIO.OUT)          //configuring 17th pin as output
GPIO.setup (27, GPIO.OUT)         //configuring 27th pin as output
                                                           #Turn LED’S ON
GPIO.output (17, GPIO.HIGH)
GPIO.output (27, GPIO.HIGH)
Time.sleep (1)                                   //sleep for one second
                                                          #Turn LED’S OFF
GPIO.output (17, GPIO.LOW)
GPIO.output (27, GPIO.LOW)
Time.sleep (1)
                                                         # Turn LED’S ON
GPIO.output (17, GPIO.HIGH)
GPIO.output (27, GPIO.HIGH)
Time.sleep (1)
                                                       #Turn LED’S OFF
GPIO.output (17, GPIO.LOW)
GPIO.output (27, GPIO.LOW)
GPIO.cleanup

LED Blinking using WHILE Loop:

#! /usr/bin/python
Import time
Import RPi.GPIO as GPIO
GPIO.setmode (GPIO.BCM)
GPIO.setwarnings (False)
GPIO.setup (17, GPIO.OUT)    //configuring 17th pin as output
GPIO.setup (27, GPIO.OUT)    //configuring 27th pin as output
                                                     #while basically means loop foreverIt executes the code if some                                                               condition is true.
WHILE 1:                                   //give one tab in the while loop to overcome the indentation error                                                            while compiling
          GPIO.output (17, GPIO.HIGH)
          GPIO.output (27, GPIO.HIGH)
          Time.sleep (1)
          GPIO.output (17, GPIO.LOW)
          GPIO.output (27, GPIO.LOW)
          Time.sleep (1)


To check the output:Type python example.py in lx-terminal.


Output 1:

Output 2:

Program for Led Glowing(ON OR OFF)

STEP 1:

Open LX-Terminal.

Create a file with .py extension

Ex: nano led.py

Nano is a type of editor used to write the code in that file named led.

Type the following code in that file by insert key or by typing letter I on keyboard.

Program:

To turn on LED’S

#! /usr/bin/python
Import RPi.GPIO as GPIO          //To import the RPi.GPIO module
GPIO.setmode (GPIO.BCM)       //Now set the mode to represent the numbering scheme you prefer.
GPIO.cleanup ()                            //Return all channels you have used back to inputs.
GPIO.setwarnings (False)            //Turn off warnings that are annoying.
GPIO.setup (17, GPIO.OUT)      //You need to set up every channel you are using as input/output.                                                              This one is an output
GPIO.setup (27, GPIO.OUT)      //Setup again but this time pin 27.
Print “Lights on”                          //To turn LEDs ON
GPIO.output (17, GPIO.HIGH)  // led on purpose
GPIO.output (27, GPIO.HIGH) //led on purpose

Save the file by typing  :wq and then press enter

To check output:Type python led.py


Output 1:

To turn off LED’S

#! /usr/bin/python
Import RPi.GPIO as GPIO           //To import the RPi.GPIO module
GPIO.setmode (GPIO.BCM)       //Now set the mode to represent the numbering scheme you prefer.
GPIO.cleanup ()                            //Return all channels you have used back to inputs.
GPIO.setwarnings (False)            //Turn off warnings that are annoying.
GPIO.setup (17, GPIO.OUT)      //configuring 17th pin as output
GPIO.setup (27, GPIO.OUT)      // configuring 27th pin as output
Print “Lights on”                          //To turn LEDs ON
GPIO.output (17, GPIO.LOW)   // led off purpose
GPIO.output (27, GPIO.LOW)   //led off purpose

To check output:Type python led.py

Output 2:


Hello World Program


STEP 1:


Open LXTerminal.

Create a file with .py extension

Ex: nano helloworld.py

Nano is a type of editor used to write the code in that file named helloworld.

Type the following code in that file by insert key or by typing letter I on keyboard.

Program:

#! /usr/bin/python                   //To ensure the correct interpreter used.
#print Hello World                 //comment line.
 print “Hello World”              //command to print the statement.

Save the file by typing  :wq and then press enter

To see the output type the following command

Ex: sudo python helloworld.py

Output:

Basic Settings On Raspberry Pi

The basic IO setup like keyboard, time zone, display:

  Open LXTERMINAL
  After opening the terminal type  “sudo raspi-config”.


    A graphical interface like this will appear


To change the keyboard layout into US layout (default: UK layout). Then select “4.Internationalisation Options”. Go to ‘select’ by using right and left arrows.

Then a menu like this will appear


and then select ‘I3’ in the optins to change the keyboard layout, and select the type of layout. Here we are using US layout (that is the regular layout used in INDIA). 

And then select type of key board which is connected to Raspberry Pi board. Here I am using Dell keyboard so that I am choosing Dell, then press OK below


The below 3 images will tell you about keyboard layout, special keys, compose key(multi key).


and the other two are



After this we have to choose the option for enabling or disabling the through special keys.

We have to configure the time zone depending upon our geographical region.


                                            Select the time zone to set the time zone .

  Here we have set the time zone of Kolkata,India.








Thursday 4 December 2014

RASPBIAN OS INSTALLATION PROCEDURE

WRITING RASPBIAN OS TO THE MEMORY CARD
          COMPONENTS REQUIRED
                SD card.
                SD formatter software.
                RASPBIAN OS.
                Win 32DiskImager software.

         First completely format the memory card.
         To format the memory card do the following procedure.
                        


         Download SD formatter software for the following link.
         Format the memory card using SD formatter software.

        Download the RASPBERRYPI OS from the following link. The recommended OS is RASPBIAN.
               http://downloads.raspberrypi.org/raspbian_latest
                       
        Unzip the file that you just downloaded.

       Download the Win32DiskImager software from the following link.
       Unzip the file and install the Win32Diskimager software in the PC.

      Writing RASPBIAN OS to the SD card:
1)    Plug your SD card into your PC.
2)    Run the file named Win32DiskImager.exe.
3)    If the SD card (Device) you are using isn’t found automatically then click on the drop down box and select it.
4)    In the Image File box, choose the Raspbian .img file that you downloaded.
5)    Click Write.


6)    After a few minutes you will have an SD card that you can use in your Raspberry Pi.

Remotely Accessing the Raspberry Pi


In the previous section we discussed how to Configure Ethernet by using Raspberry Pi. (Please click here for details.)


HOW TO CONNECT YOUR RASPBERRY PI TO LAPTOP USING LAN CABLE:

Installing/Configuring PuTTy and Xming

Click here to download PUTTY software.
Click here to download XMING software

STEP 1:

After installing the putty and xming.

Then run the putty in admin mode.

STEP 2:

In the PUTTY configuration change the host name(or IP address) with the static IP address of the Raspberry Pi.To configure IP address statically reffer to Ethernet confiuration Of Raspberry Pi.

STEP 3:

Select SSH in Category and choose X11 option.
And select "Enable X11 forwarding".


 After clicking on "Open",following terminal will appear.

Default username and password for Raspbian OS is "pi" and "raspberry".

Minimize PUTTY Terminal and open XMING software in admin mode.

Again come back to PUTTY terminal and type the command "lxsession".
After that a Raspbian OS GUI will appear on the screen.
   
 If any error occurs refer to this link.

Configuration of Ethernet on Raspberry Pi

Step 1: Review current network settings(to see the prev net config)

From the command prompt or LXTerminal:
Type the command "ifconfig" this command will display the current network settings.

Step 2: Backup the current network configuration

It is a good idea to make a backup of the interfaces file if you are new to linux:
so type the following commands in the lx terminal

sudo cp /etc/network/interfaces /etc/network/interfaces.backup

Step 3: Modify the network settings

To edit the network setting you must edit the interfaces file.  The network can use a dynamic (DHCP) IP address or a static (set) IP address.  If you want to remotely login and control the Raspberry Pi, it is a good idea to use a static IP address.

The following command can be used to update the file in the linux terminal:

sudo nano /etc/network/interfaces

Look for the eth0 line which corresponds to the Raspberry pi ethernet (RJ45) port.
edit the file to look similar to this:
iface eth0 inet loopback                                    
iface eth0 inet static

change them as to the properties of the wifi or the lan cable  that are being used by the user for  example (by using the echo wl obtaining the ip of it and changes are made as follows)

iface eth0 inet loopback                                    
iface eth0 inet static
address 10.66.12.139- the last number is as you desired(IP address depends on network connected)
netmask 255.255.255.0
gateway 1o.66.12.254
Set the address to the IP address you want the Raspberry Pi to occupy.

Once the file has been updated, use ctrl x to save and exit

NOTE:No extra new lines or the space not to be added 

Step 4: Restart the Raspberry Pi
Once the interfaces files has been updated, you must restart the Raspberry Pi for the changes to take effect.

Used to following command to restart:

sudo shutdown -r now

Step 5: Test the new network setup

Use the "ping" command to confirm that the Raspberry Pi is on the network and talking to another computer also on the network.

If you have trouble pinging other computers on the network work, check the following:


1. Confirm that the ethernet cable is firmly connected to the Raspberry Pi and network switch.
2. Confirm that the IP address, mask and gateway are correct.
3. If pinging a Windows machine, sometimes security setting prevent responding to a ping request.

For this type ping 10.66.12.138    the IP should be similar to the IP of the raspberry pi given in the previous step.

Wi-Fi on Raspberry Pi by using any USB Modem

Wi-Fi on Raspberry Pi:

A wireless usb adapter is needed for accessing Wi-Fi on Raspberry Pi.

Step-1
After plugging in the usb adapter to the usb port provided by Raspberry Pi, open the LXTerminal 
.
These commands have to be performed in the root mode .To enter the root mode, type the following command:

sudo su  

After entering into the root mode type the command:

sudo apt-get update: To get all updates in Raspbian OS 

lssub

This will list all the devices connected to the Raspberry Pi .Look for the wlan0 which confirms the reorganisation of the usb adapter by the OS.

Step-2


Install the wicd-curses, for that type the following command in the LXTERMINAL


sudo apt-get install wicd-curses

Type the following command:

sudo wicd-curses 
    
This will show all the networks available in the surrounding area.


If can’t found any wireless networks as above then click on the Prefs which is at the bottom of the above window or press P.

Then another window will open in that find that wireless interfaces is kept as wlan0, if not keep manually as wlan0.

Then click OK or press F10, by this it will save the modifications.

Then you will be back and you will see the window same as above.
Then click Refresh or press R, by this you can see the available wireless networks.

Preferably we have to select the network with 100% signal strength to avoid any errors.

Step-3

After selecting the network “ron”,we  have to configure it by clicking on the Config icon on the window opened.


In this window we have to enter the key i.e the password of the network “ron”.

Save it by clicking on the F10: OK option.

Step-4

After configuring the network ,press C in order to connect to the network.

This will take some time for obtaining the IP address. When the message is displayed that it is connected to the network “ron” , exit LXTerminal and open the Epiphany web browser 




If the desires web address is opened then our objective is completed and usb adapter is successfully configured.