Hardware Reference
In-Depth Information
try:
while True:
flash(0.5)
finally:
GPIO.cleanup()
7. For the LED to flash, it needs to be connected to the GPIO pin on your com-
puter. Do this by following these steps:
On the Raspberry Pi:
Move the wire that connects the resistor and the 3.3 volt power rail so that the
end that was connected to the power rail is now connected to GPIO 15 (labelled
as G15 on the Pi-T-Cobbler label).
On the Arduino:
Move the wire that connects the resistor and the 3.3 volt power rail so that the
end that was connected to the power rail is now connected to GPIO 15 on the
Arduino.
The Arduino board has some LEDs on the board itself, and the yellow LED on
this board indicates when the Arduino is receiving commands over the USB.
You will see this LED on the board flashing at twice the rate of the LED on your
breadboard, because each command to turn your LED on and off will cause the
Arduino's yellow LED to flash. Don't be put off by this, it is working correctly!
Running a GPIO Program
Finally, it is time to run your program and see if your LED flashes at you!
On the PC/Mac:
You can just run the program as usual from IDLE. The Arduino IO board is connected
via the USB and the PC/Mac have full access to connect to this device.
On the Raspberry Pi:
Running the program is slightly more complicated on the Raspberry Pi. You will have
to run any program that uses the GPIO differently from other programs, although it is
still useful to enter and edit your programs in IDLE. You can read more about why you
have to do these extra steps in the Digging into the Code sidebar.
1. Open the LXTerminal program from the desktop or from the menu. This will
open a command prompt window that you can use to type commands into the
Raspberry Pi.
 
Search WWH ::




Custom Search