Arduino Uno - 5V to input pin

Hello to everyone, I'm new to the Arduino's world and I do not have a great knowledge of electronic. Please forgive me for strange questions.

I would like to build a simple system to understand if 2 cables are connected and I would proceed in this way

  • 5V output port of Arduino to breadboard
  • cables 1 and 2 connected to the 5V line
  • cables 1 and 2 connected to 2 different input pins

Code will check if both cables are passing HIGH value

In future I could use a NAND gate in order to use less input ports.

Should I use any resistance between 5V port and input pins to low input mA?

The input is high impedance so will draw virtually no current if connected to an output.

HOWEVER if you short the output to ground accidently you will damage the output.

For safety put a 1k resistor from the output.

Weedpharma

Thanks weedpharma! Are you saying I have to do like attached to have a safe output?

As always.

You need to explain the context.

What are these cables? What are they connected to other than the circuit you are building?

Do you actually mean a cable tester? Simply to check cables that you would otherwise connect to something else?

In general, it is not a good idea to connect something external to the 5V supply line. You connect it to ground, and apply a voltage to the other end, from the 5V line via a 270 ohm resistor and then use a 10k resistor from the test point to an Arduino input to sense the voltage. If it is LOW, then the cable is connected and pulling it to ground, if it is HIGH, then the cable is clearly not connected.

If for some reason you want to switch the "test" on and off, then that 270 ohm resistor can be connected to an Arduino output pin instead of the 5V supply.

wgh000:
Thanks weedpharma! Are you saying I have to do like attached to have a safe output?

The way you have drawn the circuit has the resistor shorted. The line of connections that has the 5v and resistor are all connected together.

Weedpharma

Let me check I have this straight in my mind.... you want to read a pin to see if it's been taken to 5V by a wire, the other end of which is in the Arduino 5V?

If I have that correct, then that's really just this example in the IDE at File > Examples > Basics.

Not the presence of the pull down resistor to make sure the pin is low when it's not high.

Thanks guys for your infos.
Basically, I'm building a "physical game" that need, between the other things, to connect some cables (4 on the left side with 4 on the right side) together, in the correct order. Because 2 pair of cables will be there just to "confuse the ideas" (they probably will not be connected to anything), when the 2 right pair of cables will be connected, I need to receive an input to activate the next part of the game.

I hope I've better explained what I need to do.

Basically then the wire is a switch. When connected it acts as a closed switch and when disconnected it acts as an open switch.

Weedpharma

wgh000:
in the correct order.

That's new: puts a different spin on it.....

The example I linked shows you how to read a pin, which is still something you need to do. So get that clear in your mind and working.

Then before you code any further, I'd suggest you think through how you would manually test for the 2 wires being connected in the correct sequence.

You might have to check first, for example, that A is connected and B is not... if so, how will you record that fact, so that when B is connected you know it's successful? Your system needs to be in some kind of "waiting for A" state right at the start, then "waiting for B" when A is connected. But when it's "waiting for A" and B is connected out of sequence, then what.

This is a really good example of what's known as a finite state machine, and you might like to read this link. You'll be more successful if you think this through before you dive into code.

But as I say, make sure you know how to read a switch first, and look at if - else while you're at it.

The way you have drawn the circuit has the resistor shorted. The line of connections that has the 5v and resistor are all connected together.

Yes, I think connecting both ends of the resistor to the same row of pins on a breadboard is a red flag.
From this point on, anything can happen...

BTW, when is the assignment due ?

weedpharma:
Basically then the wire is a switch. When connected it acts as a closed switch and when disconnected it acts as an open switch.

Does this mean that I can just bring 5V (for example taken from the 5V pin) to an input pin and read there an HIGH state?

Or should I protect the pin with a resistor?

About programming anything worry me (developer already 8 years), my lack is in electronic and fear to broke Arduino...

Yes, I think connecting both ends of the resistor to the same row of pins on a breadboard is a red flag. From this point on, anything can happen...

Does this mean that I can just bring 5V (for example taken from the 5V pin) to an input pin and read there an HIGH state?

Inputs are HIGH IMPEDANCE. They can be directly shorted to 5V or GND without damaging anything.
I'm not sure why you would use the 5V power pin though. Why do you want to make the input HIGH ?

What can I do otherwise?

Each input pin requires it's OWN pullup resistor. you can't share them like your wiring diagram. If one of them is an input then that's different but your Fritzing was wrong and you haven't corrected it. The resistor
is shorted to itself. 10 k ohm is the correct value for the pullup. FIX YOUR FRITZING .