I have small problem with a circuit I'm designing.
I have two illuminated pushbutton switches, which are SPDT. One red, one green.
The red switch turns on the power to the arduino, and it is simple enough to wire the led for that up so that the light turns on when it is depressed.
The green switch however is a switch I need to know the state of. And it too needs to illuminate when it is pressed.
The problem is, I've looked at the wiring diagram for how to connect a switch and sense whether it is pressed or not...
...but I'm not sure if I can drop an LED in there without screwing something up.
Also, I was really hoping to power that green LED directly off the 9v battery, because I'm already drawing a ton of current from the Arduino for other leds. If there is a simple way to wire it so it will illuminate when the switch is pressed, but it would draw the current from the battery instead of the Arduino, that would be most excellent.
If all else fails, I could get a DPDT switch, but they're almost twice as expensive, so I'd like to avoid that if possible.
Could an led be put in parallel to a pullup resistor?
I think I have once accidentally stumbled on that when using a button on pin 13 on a duemilanove.
Could an led be put in parallel to a pullup resistor?
Yes, as long as the LED also has it's own series resistor wired also. Otherwise when the switch is pressed there would be a full +5vdc across the LED with no current limiting.
Could an led be put in parallel to a pullup resistor?
Yes, as long as the LED also has it's own series resistor wired also. Otherwise when the switch is pressed there would be a full +5vdc across the LED with no current limiting.
I guess that's what I'll have to do then. I just looked on Mouser, and though they have it in their catalog they don't seem to actively stock the DPDT version of the switch I need.
I guess I'll just have to find 15-20mA of current to power it.
+ve is the 5v pin on the arduino, right? Won't that then draw current from the Arduino's voltage regulator, which can only supply 200mA?
I'm already near the limit with this design, which is why I was looking for a way to draw the current directly from the battery, as I will be doing with the power switch.
I'll be posting a schematic of the design today btw, and would be greatful if you could have a look over it.
on't that then draw current from the Arduino's voltage regulator, which can only supply 200mA?
No the limit on the arduino's regulator is not 200mA. That is the limit on the combined current output from the arduino's pins.
The regulator limit is defined by the power dissipation which is dependent not only on the current but on the voltage supply. Basically the closer you can get it to 7.5V the less power it dissipates from a given current. http://www.thebox.myzen.co.uk/Tutorial/Power_Examples.html
So, based on your tutorial, I'm running the Arduino off 9v, so if I subtract 5.7 volts from that I get 3.3v that need to be dissipated.
Then, calculating the power I need, the Arduino itself draws 120mA, and I'm drawing 175mA of current from it to power all my components, so I need a total of 295mA.
Multiplying 3.3v by 295mA, I get 0.9735 watts, which is less than 1.5 watts. That puts me in the clear.
And finally, if I divide the max I can draw, 1.5 watts, by 3.3v, the amount I need to dissipate, that gives me 454mA, which is the amount of current I can safely draw form the regulator without overheating it.
So, in theory, if I wanted to, even though I'm drawing 175mA from the Arduino's pins, I could also run both my illuminated pushbuttons off the 5v pin, and safely draw another 40mA of current for those.
Not sure where you get this figure from it is a 5V regulator so you should subtract 5V.
An arduino by itself not powering anything else takes about 30 - 50 mA.
200mA is not what you can draw safely it is the absolute maximum. The data sheet says:-
Stresses beyond those listed under “Absolute Maximum Ratings” may cause permanent damage to the device. This is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational sections of this specification is not implied. Exposure to absolute maximum rating conditions for extended periods may affect device reliability.
Not sure where you get this figure from it is a 5V regulator so you should subtract 5V.
I got it from your tutorial:
The regulator drops the difference between the input voltage and the output voltage. Also their is a series diode in front of the regulator so that drops 0.7V. This gives us a total voltage drop across the regulator of 12 - 5 - 0.7 = 6.3V.
I'm running off 9v, so 9 - 5 - 0.7 = 3.3v
An arduino by itself not powering anything else takes about 30 - 50 mA.
Oh, even better!
200mA is not what you can draw safely it is the absolute maximum.
Yes, you are right of course. But the current draw I'm calculating is the worst case scenario for my circuit. It's what may be drawn at some point for brief periods. The actual current draw however in general should be much lower. My display is my biggest current draw, and most of the time, the whole thing isn't going to be lit. Most of the time, half of it isn't even going to be lit. Also the piezo will be beeping periodically for only 1/100th of a second, and the leds on the antennas will be PWM so they won't be drawing full current all the time either.
On average, I'd say the circuit probably won't be drawing more than 100mA. Maybe 150mA when the user cranks the speed up and most of the display is lit.
Is this still too much? I don't know. The spec sheets don't give a reccomended maximum. I can use slightly bigger resistors for the display though if it comes to that. Get that 160mA max down to 144mA or 120mA.
Avrage is important for power deratings but peak is important for staying within the maximum.
The spec sheets don't give a reccomended maximum.
No they seldom will, it is because engineers will derate or reduce the maximum depending on how conservative they are being. Typically you will derate to 80% of the maximum although some guide lines say 60%. The more you derate the more reliable will be the circuit and you have a higher MTBF (mean time between failures).
If you have any doubt I would shave some current off the LED as it is hard to notice the difference between 20mA and 18mA in an LED. On the other hand multiplexing it is going to make it look dimmer anyway.