Nuffnang Ads

Wednesday, 10 September 2014

Raspberry Pi GPIO - Simple LED example

This time the tutorial is very simple. Turn on and turn off an LED that connected to GPIO pin.

1) Hardware preparation:-

  • LED
  • resistor ( prefarably less than 1k ohm)
  • crocodile clips or any connectors to the GPIO pin.
2) Solder the LED and resistor together with clips.

3) Connect the positive terminal to the one of the GPIO pins, in this tutorial is GPIO4, and negative terminal to the GND pin or connect to any ground.

USB socket also can be ground

4) Turn on Raspberry Pi and get access to terminal. Type the following command to turn on the LED

$ sudo su
# cd /sys/class/gpio/
# echo 4 > export                     //in this tutorial GPIO4 is used
# cd gpio4
# echo out > direction             //to declare as an output pin
# echo 1 > value                     //to give HIGH output to the GPIO4

LED on

5) Command to turn it off is :-
# echo 0 > value

LED off

GPIO commands


No comments:

Post a Comment