Hardware Reference
In-Depth Information
Figure 10-14. A finished breadboard connected to the Raspberry Pi
That's all the hardware work! The last thing you may want to do is ensure that the remote button you have wired
to the breadboard is mated with the mains plug. For my unit I had to hold the on button for a few seconds until the
mains unit stopped flashing. You are still able to use the remote control buttons as you normally would at this point in
time. It may be a wise idea to make sure that your remote control and mains unit work before moving on to the next
section. Now that you know the unit works, it's time to make it work from the Raspberry Pi.
The Soft Side
Log in to the Raspberry Pi. Just like in Chapter 5, you're going to need to export the GPIO pins and configure them first.
Using the GPIO Pins as Output
First, export the two pins with the following command:
# echo 4 > /sys/class/gpio/export && echo 17 > /sys/class/gpio/export
Once that is done you need to set the GPIO pins as an output this time. Unlike in Chapter 5 where you detected
the high or low state of the external circuit, this time you want to set the external circuit high or low. To do that, run the
following command:
# echo out > /sys/class/gpio/gpio4/direction && echo out > /sys/class/gpio/gpio17/direction
Now it's time to see if you got your hardware corrected right. Run this command to turn on your mains device:
echo 1 > /sys/class/gpio/gpio4/value
 
Search WWH ::




Custom Search