Python and IO Pi Experiments
- 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.
- 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.
3. The resistor should be selected by making use of the following tables for the color combination.
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.
6. Now, connect the Raspberry PI to the power supply and the LED starts to light ON which is showed in the below figure.
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.
3.3 Volts supply
5 Volts supply
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:
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.
Commands are :
sudo nano config.txt
save and exit
Lists all the files present when given ls:
Given the below command, we get 59 lines where in we enable the audio.
Need to add enable command in order to get the PI booted up.
Given the below command, the PI gets shut down and slowly get booted up.
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.
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.
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.