Controlling the Raspberry Pi's GPIO pins is surprisingly simple using the GPIO command-line interface.
First, install the GPIO command-line tools by running this:
git clone git://git.drogon.net/wiringPi
cd wiringPi/
./build
Verify that the gpio command-line tool has been installed by running this:
gpio -v
Let's say we have an LED connected to pin 4 (to be more specific, the positive end is connected to pin 4 and the negative end is connected to one end of a resistor, whose other end is connected to the ground pin).
This circuit is similar to the pin-low Write mode we discussed earlier.
You can test this circuit through the following steps:
- Set the pin 4 to output mode:
gpio mode 4 output
- Set the pin to high:
gpio write 4 1
You should now see the LED glowing.
- Set the pin to low:
gpio write 4 0
The LED should...