Basic Elelctroncis Question in 2 parts

hi everyone

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.

  1. 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 ?

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

Many thanks

Mike

511568b6ce395f1b40000000.jpg

Why not use the built-in pullups?

AWOL:
Why not use the built-in pullups?

I guess I could do for the part 1 answer but have always thought it better to add my own protection (just in case of a coding mishap) ?

3k3 sound like pull up values for the I2C bus, not for switches.
10k is more common, but you don't have to.

Connect the switch between pin and ground, and as AWOL said, use the build-in pull up.
No resistor needed.

pinMode(switchpin, INPUT_PULLUP);

Google "Arduino screw shield" (images).
Leo..

fair enough, just from a curiosity point of view though, IF done externally, would I have needed to use 10 of them or just 1 ?

Any the LED issue ?

Cheers

Every switch needs it's own (internal) pull up resistor.

Connect a "LED + current limiting resistor" between 5volt and pin (switch), and you can control the LED as well as the pin.
Leo..

Ah before the switch - I had mine after the switch, any idea's why this stopped the arduino from registering the input ?

Apologies if these are silly questions but I am really keen to learn

AWOL:
Why not use the built-in pullups?

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.

  1. Always need one pullup per signal - a voltage cannot simultaneous be 10 different values!!
  2. Use blue or white LED.

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.

  1. Always need one pullup per signal - a voltage cannot simultaneous be 10 different values!!
  2. Use blue or white LED.

Cables are probably going to be around 2-4 meters of 0.5mm multistrand cable

  1. Fair comment
  2. Why blue or white (not that it matters about the colour anyway)

Cheers

MarkT:
2) Use blue or white LED.

Why ?

Ah just read that LEDS are 3.2 ->3.8v so I guess I'm needing to be using the 3.3v voltage on my input board rather than the 5v

No...

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

Oh. Just when I thought i was getting an understanding of thing. Lol.

So what about the 3k3 resistor. I don't have the skills or software to draw a schematic. Do I go....

5v to 220 resistor to led to 3k3 resistor to input to switch to ground ?

Project_Mike:
Cables are probably going to be around 2-4 meters of 0.5mm multistrand cable

  1. Fair comment
  2. 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.

I'm confused.

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

Order a resistor selection/collection.

Put the LED in series with the external pull-up.

+5v —— >| —— pullup —— input pin —— switch —— GND

larryd:
Order a resistor selection/collection.

Put the LED in series with the external pull-up.

+5v —— >| —— pullup —— input pin —— switch —— GND

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 ?