Jiggles
Posts: 9
Joined: Tue May 29, 2012 11:59 am
Location: Edinburgh, Scotland
Contact: Website

LED on boot

Wed Jun 26, 2013 5:54 am

How would I go about making an LED come on when Rasbian is fully booted?
Last edited by Jiggles on Wed Jun 26, 2013 8:01 pm, edited 1 time in total.

User avatar
rpdom
Posts: 15431
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: LED on boot

Wed Jun 26, 2013 7:33 am

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.

drsoupy
Posts: 14
Joined: Fri May 31, 2013 4:03 am

Re: LED on boot

Wed Jun 26, 2013 7:37 am

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?
Last edited by drsoupy on Wed Jun 26, 2013 7:53 am, edited 1 time in total.
- Dr.Soupy

User avatar
joan
Posts: 14378
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: LED on boot

Wed Jun 26, 2013 7:44 am

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).

SteveSpencer
Posts: 351
Joined: Thu Mar 28, 2013 9:19 am
Location: Nottingham, UK

Re: LED on boot

Wed Jun 26, 2013 7:59 am

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.
Steve S
No, I can't think of anything funny that won't offend someone if they want it to...

User avatar
rpdom
Posts: 15431
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: LED on boot

Wed Jun 26, 2013 8:03 am

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 ;)

drsoupy
Posts: 14
Joined: Fri May 31, 2013 4:03 am

Re: LED on boot

Wed Jun 26, 2013 8:04 am

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
- Dr.Soupy

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: LED on boot

Wed Jun 26, 2013 8:39 am

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.
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

Jiggles
Posts: 9
Joined: Tue May 29, 2012 11:59 am
Location: Edinburgh, Scotland
Contact: Website

Re: LED on boot

Wed Jun 26, 2013 7:08 pm

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:

Return to “General programming discussion”