Page 1 of 1

LED on boot

Posted: Wed Jun 26, 2013 5:54 am
by Jiggles
How would I go about making an LED come on when Rasbian is fully booted?

Re: LED on boot

Posted: Wed Jun 26, 2013 7:33 am
by rpdom
Connect it with a resistor to one of the GPIO lines and ground. Then put the following in /etc/rc.local (just before the "exit 0" line)

Code: Select all

# I'm using GPIO 4 (pin 7 of connector P1) as an example
echo "4" >/sys/class/gpio/export
echo "out" >/sys/class/gpio/gpio4/direction
echo "1" >/sys/class/gpio/gpio4/value
That will light the LED at the end of the boot sequence.

Re: LED on boot

Posted: Wed Jun 26, 2013 7:37 am
by drsoupy
rpdom wrote:Connect it with a resistor to one of the GPIO lines and ground. Then put the following in /etc/rc.local (just before the "exit 0" line)

Code: Select all

# I'm using GPIO 4 (pin 7 of connector P1) as an example
echo "4" >/sys/class/gpio/export
echo "out" >/sys/class/gpio/gpio4/direction
echo "1" >/sys/class/gpio/gpio4/value
That will light the LED at the end of the boot sequence.
Sorry if this is a dumb question but I'm kinda new, so my Pi booted up, the LED came on, but didnt turn off, is there a way to make it turn off?

Re: LED on boot

Posted: Wed Jun 26, 2013 7:44 am
by joan
You'll need to get a LED and a 400-600 ohm resistor (you can't use the on-board LEDs for this purpose). Take a wire from the gpio to the resistor. Connect the other end of the resistor to the anode of the LED. Connect the other end of the LED to a Pi ground pin. See http://elinux.org/Rpi_Low-level_peripherals (GPIO).

Re: LED on boot

Posted: Wed Jun 26, 2013 7:59 am
by SteveSpencer
drsoupy wrote:
rpdom wrote:Connect it with a resistor to one of the GPIO lines and ground. Then put the following in /etc/rc.local (just before the "exit 0" line)

Code: Select all

# I'm using GPIO 4 (pin 7 of connector P1) as an example
echo "4" >/sys/class/gpio/export
echo "out" >/sys/class/gpio/gpio4/direction
echo "1" >/sys/class/gpio/gpio4/value
That will light the LED at the end of the boot sequence.
Sorry if this is a dumb question but I'm kinda new, so my Pi booted up, the LED came on, but didnt turn off, is there a way to make it turn off?
Yes.

Code: Select all

echo "0" >/sys/class/gpio/gpio4/value
will do it.

Re: LED on boot

Posted: Wed Jun 26, 2013 8:03 am
by rpdom
Ah, didn't realise you wanted it to go off again.

Do as SteveSpencer just said, but put a "sleep 2" between the two bits of code to make it stay on for 2 seconds (or longer if you wish), otherwise it will blink so quickly that you won't see it ;)

Re: LED on boot

Posted: Wed Jun 26, 2013 8:04 am
by drsoupy
SteveSpencer wrote:
drsoupy wrote:
rpdom wrote:Connect it with a resistor to one of the GPIO lines and ground. Then put the following in /etc/rc.local (just before the "exit 0" line)

Code: Select all

# I'm using GPIO 4 (pin 7 of connector P1) as an example
echo "4" >/sys/class/gpio/export
echo "out" >/sys/class/gpio/gpio4/direction
echo "1" >/sys/class/gpio/gpio4/value
That will light the LED at the end of the boot sequence.
Sorry if this is a dumb question but I'm kinda new, so my Pi booted up, the LED came on, but didnt turn off, is there a way to make it turn off?
Yes.

Code: Select all

echo "0" >/sys/class/gpio/gpio4/value
will do it.
EDIT: never mind, rpdom answered my question!

Thanks

Re: LED on boot

Posted: Wed Jun 26, 2013 8:39 am
by DeeJay
rpdom wrote:Ah, didn't realise you wanted it to go off again.
I think it's what cynical developers call "feature creep". Or what users think is "obvious".

The solution suggested met the original requirement.
How would I go about making an LED come on when the Rasbian is fully booted?
Seriously - a tiny but very interesting example of why the way we use English is not always good enough for specifying what we want a system to do.

Re: LED on boot

Posted: Wed Jun 26, 2013 7:08 pm
by Jiggles
OP here. It was someone else asking for it to go off again. I was happy with it coming on and staying on! :D Thanks for the help guys. I knew it was gonna be something simple but the GPIO stuff confuses me!

My thread was just hijacked by others who were interested in the same thing. :shock: