Hi
I'm planning a simple project to add a shutdown button to a Raspberry Pi. Basically, when a button is pressed and held for a couple of seconds the Pi will issue a shutdown command.
For feedback I'm thinking something along the lines of, once the button press is detected I want to light an LED and, once the time held has been reached to issue the shutdown command, light another LED (or probably change the colour using an RGB LED).
I might add a small buzzer when the button is pressed in case it's being pressed on by something accidentally.
I don't really have any experience of electronics past a little electrical set I had about 40 years ago but I've always been interested.
The 'Build Raspberry Pi Controllers: LED Flasher' series of articles by Don Wilcher are a great start for ideas on what can be done and how, but I have a couple of questions ...
1) Is the opto-isolator really necessary when driving the LED? Or could a transistor be used given that the power is coming from the Pi anyway?
I'm guessing it's there because the GPIO is 3.3v and it's using the 5v supply line for the LED (and presumably I'm incorrect in thinking that a transistor would work). Presumably it wouldn't be necessary if using the 3.3v supply though?
2) I am actually planning on using the opto-isolator (despite question 1) as I'm planning on powering the LED with an external source (3v battery). I'm thinking that I should connect the -ve from the battery side of the circuit to the Pi's ground, is that correct or should they stay separate?
(Why a battery when there's a perfectly good Pi with 3.3 and 5v supplies? I have a small touchscreen which I haven't used yet other than a quick test to make sure it works. If this were to be plugged into the Pi at the same time then it would cover the lower 26 pins meaning no easy access to the +ve pins. Also, I have a couple of new 3v button cells that aren't any use anymore so I thought I might as well use those rather than worry about stacking connections or similar.)
Thanks for reading this, I'd be grateful for any help.
I'm planning a simple project to add a shutdown button to a Raspberry Pi. Basically, when a button is pressed and held for a couple of seconds the Pi will issue a shutdown command.
For feedback I'm thinking something along the lines of, once the button press is detected I want to light an LED and, once the time held has been reached to issue the shutdown command, light another LED (or probably change the colour using an RGB LED).
I might add a small buzzer when the button is pressed in case it's being pressed on by something accidentally.
I don't really have any experience of electronics past a little electrical set I had about 40 years ago but I've always been interested.
The 'Build Raspberry Pi Controllers: LED Flasher' series of articles by Don Wilcher are a great start for ideas on what can be done and how, but I have a couple of questions ...
1) Is the opto-isolator really necessary when driving the LED? Or could a transistor be used given that the power is coming from the Pi anyway?
I'm guessing it's there because the GPIO is 3.3v and it's using the 5v supply line for the LED (and presumably I'm incorrect in thinking that a transistor would work). Presumably it wouldn't be necessary if using the 3.3v supply though?
2) I am actually planning on using the opto-isolator (despite question 1) as I'm planning on powering the LED with an external source (3v battery). I'm thinking that I should connect the -ve from the battery side of the circuit to the Pi's ground, is that correct or should they stay separate?
(Why a battery when there's a perfectly good Pi with 3.3 and 5v supplies? I have a small touchscreen which I haven't used yet other than a quick test to make sure it works. If this were to be plugged into the Pi at the same time then it would cover the lower 26 pins meaning no easy access to the +ve pins. Also, I have a couple of new 3v button cells that aren't any use anymore so I thought I might as well use those rather than worry about stacking connections or similar.)
Thanks for reading this, I'd be grateful for any help.