Setting Up the Gertboard for Output
The beauty of the Gertboard is that it already has all the components on the board for you, so all you
need to do is connect some jumpers and wires.
Try It Yourself: Build the Gertboard Circuit
The Gertboard makes developing circuits a snap! Here are the steps you need to
follow:
- Connect a jumper to the 3.3V power supply side in the J7 block (the middle pin to
the top pin). - Connect a wire from the GP18 pin in the J2 block to the B12 pin in the J3 block.
This redirects the GPIO 18 signal to the I/O buffer 12 area on the Gertboard. - Connect a jumper between the two B12 output pins, directly above the U5 chip.
This circuit uses the D12 LED in the row of LEDs at the top of the Gertboard for the output LED.
When the GPIO 18 signal goes HIGH, the LED lights up, and when it goes LOW, the LED goes out.
Now you’re ready to start testing the GPIO output!
Testing the GPIO Output
You should test the GPIO output before you start coding. To do this, you can run a test directly from
the Python v3 command prompt to turn the LED on and off, using the GPIO output signal.
Because the RPi.GPIO module accesses the GPIO pins using direct memory access, you must run
commands at the Python v3 command prompt as the root user account using the sudo program, as
shown in this example:
Click here to view code image
pi@raspberrypi ~ $ sudo python3
Python 3.2.3 (default, Mar 1 2013, 11:53:50)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
You need to set the GPIO.BCM mode and set up the GPIO pin 18 signal for output:
Click here to view code image
>>> import RPi.GPIO as GPIO
>>> GPIO.setmode(GPIO.BCM)
>>> GPIO.setup(18, GPIO.OUT)
>>>
Now you can turn the LED on and off by using these two commands:
Click here to view code image
>>> GPIO.output(18, GPIO.LOW)
>>> GPIO.output(18, GPIO.HIGH)
Toggle back and forth a few times and watch the LED turn on and off. Then you use the cleanup()
method to return the GPIO ports back to a neutral setting, like this:
>>> GPIO.cleanup()