I've just purchased a Arduino Mega for a little robot project I wish to build. I have very good programming skills but alas not so good on electronics. I wish to make a 10 way input board out of verobaord to accommodate screw terminals for the external switches etc, I'll also add a manual switch (in parallel) to these so that I can trigger it manually. essentially I am repeating the pullup circuit 10 times.
I have read to use a 3k3 resistor in the pullup circuit but my question is that would I have to use a resistor for each input (ie 10 resistors for the 10 inputs) or do I just attach 1 x 3k3 resistor to the circuit directly after the 5v and then distribute from there ?
What would be really nice is if I could attach a LED after the switch so that i can see if the external switch is open or closed on the vero board. When I connect one however it lights up dimly when I press the button but doesnt register the state on the arduino any more.
I appreciate these are probably very basic electronic concepts but I really would appreciate some guidance.
Because we don't know how long the cables are going to be. 3k3 is a reasonable value of
external pullup for external wiring, the internal pull-ups are too weak for long external cables.
Always need one pullup per signal - a voltage cannot simultaneous be 10 different values!!
MarkT:
Because we don't know how long the cables are going to be. 3k3 is a reasonable value of
external pullup for external wiring, the internal pull-ups are too weak for long external cables.
Always need one pullup per signal - a voltage cannot simultaneous be 10 different values!!
Use blue or white LED.
Cables are probably going to be around 2-4 meters of 0.5mm multistrand cable
Fair comment
Why blue or white (not that it matters about the colour anyway)
LEDs need a current limiting resistor in series.
That current limiting resistor needs some voltage headroom to keep LED current constant.
5volt is perfect for a ~3.3volt LED.
~3.3volt across the LED, and ~1.7volt across the current limiting resistor.
Use Ohm's law to calculate the resistor for the required LED current.
Or just use a 220ohm resistor.
Leo..
Project_Mike:
Cables are probably going to be around 2-4 meters of 0.5mm multistrand cable
Fair comment
Why blue or white (not that it matters about the colour anyway)
Cheers
3.2V forward voltage, will read as high. Actually probably a bit lower than that unless
the pull-up is a lower value like 470 or 1k, but other colour LEDs are definitely too low
a forward voltage to read as high reliably.
A red LED with a forward voltage of 1.4V or so will never allow the Arduino pin to see a logic HIGH, it
clamps the voltage to a max of 1.4V which is guaranteed to read as LOW
A blue LED with a forward voltage of 3.2V will allow a pin to read high (3.0V is the lower limit for
guaranteed HIGH for the ATmega microcontrollers powered at 5.0V).
One pull up resistor only. With an LED present it is acting as current limiting for the LED until
the switch closes.
Will the led add additional resistance. Trying it out just now. The 3k3 is very dim but still visable. A 160 is very bright. I reckon a 1k is going to be about right but I'll need to order some.
A length of 10m of the cable is showing as 1 ohm so I think I can disregard that issue.
I wish I understood how this worked rather than trial and error. I've looked at ohms law and understand the formula but can't see how amps comes into play in this example
Well that's not going to work reliably, you need to actually pull up with a decent resistance, and an LED is
practically infinite resistance a volt below its forward voltage, so this is likely to act like the pin is floating and pick up noise. Add 10k in parallel with the LED to get reliable behaviour. Or be limited to red LEDs.
Wow I am just amazed at all of the different answers I am getting from what I thought was a very simple question.
MarkT - your solutions adds a whole new dimension to it, My tests with the 1k seems to be working just so - do you think I could have problems long term doing it this way ?