Thursday, July 17, 2014

How to switch on LED on board using Raspberry pi


Hello folks !
Welcome to raspy tutorial ...


This post is for switching a LED light using terminal in raspberry pi.


To do this activity you need to get Administrative rights first of all. So, type the following commands in your terminal.

$sudo su
$/home/pi#


Here su is "Super User" by firing this command you will get the administrative rights and you can access the hardware with full authority.


Now, check on which pin you want to ON the LED take an example pin number 24,so type the following command...

echo 24 > /sys/class/gpio/export

 Here echo commands writes that pin number to be ON.
this path /sys/class/gpio contains the pin directory and files.
By firing that command a new folder will generate under the same path /sys/class/gpio/gpio24.

Now switch to the created path
i.e. /sys/class/gpio/gpio24

So, use CD command with above path (CD stands for Change Directory )

cd /sys/class/gpio/gpio24
then type ls to see what files it contains.

Now to set the connected pin as LED on or off type in terminal

echo out > direction

Now to ON it type
echo 1 > value

And to turn it off type

echo 0 >  value

This is how you can play with LED placed on your board.Thank you for reading it with too much patience and feel free to comment :)

No comments:

Post a Comment