Python and IO Pi Experiment

Python and IO Pi Experiments

  1. Connect the bread-board and the Raspberry PI by means of a bus that acts as a connector for both of them.  Ensure that the pins are properly set in the bread-board and the PI, else loose connection might lead to unsuccessful outputs.
  2. Now, the experiment says that we would require a LED, a 270 ohms resistor and the Raspberry PI GPIO pins serve as the voltage and ground for the circuit as shown in the below figure.

515c7a2bce395f653d000002.png ledlabel

rpi_gpios-131x300

3. The resistor should be selected by making use of the following tables for the color combination.

resistor-color-code-all

3.  Based on this, I had 200 ohms resistor and so I have connected two 200 ohms resistors in series so that it could be sufficient for the 270 ohms that was required in question.

4.  Now, start up the connections with the diode such that the cathode(short lead) has  series connection with that of the resistors connected in series and the other end of the resistor is to be connected to the ground.

5. The anode (long lead) is to be connected to that of the 3v of that of the GPIO pins in the top.  Below is the figure that shows the connections of the same.

IMG_2433.JPG

6.  Now, connect the Raspberry PI to the power supply and the LED starts to light ON which is showed in the below figure.

whatsapp-image-2017-02-07-at-11-26-22-am

7.  Now, make use of the USB for the connection between your laptop and the Raspberry PI set up that we had just connected.  The below is the figure of the USB, it has 5 plugins viz.

Ground(GND)

Transmitter(TX)

Receiver(RX)

3.3 Volts supply

5 Volts supply

usbToTTL.jpg

8. Install the USB to serial drivers specific to the adapter used! For the hardware above, PL2303 drivers can be found on the below URL:

https://www.guard1.com/Support/KB/Content/Hardware/Unable-to-install-Prolific-USB-to-Serial-Comm-Port-driver—Windows-Vista-and-7.htm

9. Reboot the computer.

10.  Check the status of the ports in the Device manger of the laptop and look if it’s running safely.  If there is a warning symbol, it means that the port is broken or it doesn’t exist where in we would have to uninstall and reinstall back.  Do not forget to reboot your computer several times until you see that the ports are showing clean status on the device manager.

11. Once done, we need to ensure that we connect a keyboard with mouse to the Raspberry PI and of course a monitor to run few essential commands in the Linux console to get the PI booted up.

whatsapp-image-2017-02-06-at-11-38-41-pm

Commands are :

cd /boot

ls

sudo nano config.txt

enable_uart=1

save and exit

shutdown now

Lists all the files present when given ls:

whatsapp-image-2017-02-06-at-11-38-42-pm

Given the below command, we get 59 lines where in we enable the audio.

WhatsApp Image 2017-02-06 at 11.38.49 PM.jpeg

 

Need to add enable command in order to get the PI booted up.

whatsapp-image-2017-02-06-at-11-38-44-pm

Given the below command, the PI gets shut down and slowly get booted up.

whatsapp-image-2017-02-06-at-11-38-52-pm

 

 

12. Disconnect the normal power supply from Raspberry Pi.   This is essential, since we’ll be supplying power from the USB port instead. If you simultaneously supply power from your computer’s USB port and from the wall,  Raspberry Pi will get burnt.

13.   Make sure the connections from that of the USB goes the correct terminals on the other side, the connections must look like the below in figure.

14. On the Raspberry Pi side, connect P02 (5v), P06 (GND), P08 (Tx and/or GPIO 14), and P10 (Rx and/or GPIO 15) jumpers. It’s very important to note that the Tx from the adapter’s USB side goes to the Rx for the Raspberry Pi side, and the Rx from the adapter’s USB side goes to Tx for the Raspberry Pi side.

whatsapp-image-2017-02-07-at-11-26-24-am

15. Make sure and double check all of your connections before you plug in the USB adapter.  Make sure the normal Raspberry Pi power cable is NOT connected.

16. Plug in the USB end of the adapter to the laptop or computer.

17. Wait one minute for Raspberry Pi to boot.

18.  Now the LED gets ON getting the power from the USB.

WhatsApp Image 2017-02-07 at 11.26.25 AM.jpeg

Python Program:

Now, we are writing “Hello World” program in Python as we normally write Hello world code for any language or environment for the first time.

We use any text editor to create these files, we could use is one built-in to the Python packages on the Pi:

1. In the Python Shell, on the Application Menu, click File and then click New Window.

2. Type print(“Hello, World”)

3. On the Application Menu, click File and then click Save As and save the file with the extension .py.

4. On the Application Menu, click Run and then click Run Module. The results of the program are shown in the Python Shell.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s