How to send a signal from one pin to another?

Hi all,

I'm trying to create a simple puzzle:

There are 3 wires: red, green, and blue.

There are 3 pins: pin 1, pin 2, and pin 3.

I simply want the user to attempt to guess which wires goes into which pin.

When they get the correct combination, I will trigger the phrase "SUCCESS" in the Serial monitor.

For example:

IF (Red wire is connected to Pin 2 && Green wire is connected to Pin 1 && Blue wire is connected to Pin 3)
{

Serial.println("SUCCESS!");

}
Else
{
Serial.println("You haven't figured it the right combination yet!)"
}

This will be incorporated as part of a larger puzzle... Initially I was thinking that the red, green, and blue wires could simply be connected to three digital pins, each with a different PWM signal value which could then be read by the Analog Pins. Unfortunately I can't seem to figure out how to make that work (code wise)...

So basically, is there a way for me to connect to pins on the Arduino (e.g. Digital Pin 2 to Analog Pin A0) and have it read a specific numerical value of some kind? This way, I can assign the Red wire, Green Wire, and Blue wire different numerical values so I know which one is connected.

Thank you!
Arjun

coolarj10:
Initially I was thinking that the red, green, and blue wires could simply be connected to three digital pins, each with a different PWM signal value which could then be read by the Analog Pins. Unfortunately I can't seem to figure out how to make that work (code wise)...

Of course, the problem there is that you do not understand what PWM and Analog pins are. :grinning: Never mind.

This mistaken notion has been posted here before - perhaps more than once. :roll_eyes:

The solution to your problem is far simpler and more general than you realise. Of course, your "wires" are themselves connected to Arduino pins. Note first that you need to consider using diode arrays to protect these wander wires and "pins" from static discharge. :astonished:

OK, you have a number of Arduino pins used; it does not matter whether they connect to your wander wires or pins. Set them all to pinMode of INPUT_PULLUP.

Now set one at a time to OUTPUT and pinWrite it LOW. Read all the other pins and see which one has been pulled LOW because it is connected to the present one. Now set the first one back to INPUT_PULLUP and set the next to OUTPUT and LOW; read all the other pins (except the one you have previously pulled LOW).

Repeat this for all pins, you test fewer each time as the previous have already been tested. You end up finding out what is connected to what even if two wander leads or two pins have somehow been connected. :sunglasses:

What is discussed in Reply #1 will identify which pins have a wire connected and which do not. But it won't identify the particular wire that is connected to a pin - which, it seems, is what the OP wants.

To identify a wire it must have some identifiable characteristic and one way to do that is with resistors, Suppose you have the wires organised like this (when I say "Red Wire" I mean one end of the red wire etc.)

Arduino GND ---- Red Wire ---- 10k resistor --- Green Wire ---- 10k resistor ---- Blue wire --- Arduino 5v

Now, if you connect the other ends of the three wires to any of the analog pins and use analogRead() it will show 0 for the red wire, 1023 for the blue wire and 512 (approx) for the green wire.

...R

Robin2:
What is discussed in Reply #1 will identify which pins have a wire connected and which do not. But it won’t identify the particular wire that is connected to a pin - which, it seems, is what the OP wants.

Rubbish! :cold_sweat:

coolarj10:
Initially I was thinking that the red, green, and blue wires could simply be connected to three digital pins, each with a different PWM signal value which could then be read by the Analog Pins.

The Subject title: “How to send a signal from one pin to another?”

Paul__B:
Rubbish! :cold_sweat:
The Subject title: "How to send a signal from one pin to another?"

In that case perhaps you would like to review your text for clarity :slight_smile:

...R

It is actually, the same problem - or at least, the same solution - as having jumper leads with a set of pin sockets so that any pin socket can be connected to any other; this is just the "degenerate" case when one end of the wander lead is tethered. :grinning:

Also similar to a couple of previous examinations of keyboards where the "rows" and "columns" are the same, similar to "Charlieplexing".

Thank you so much both! Paul__B, I appreciate the detailed explanation about the generalized case!

I think Robin2’s explanation tackles what I am trying to do in the most straight forward sense, because that’s reallY what I’m trying to do: have each wire have some defining characteristic that makes it easy to identify.

Sorry if my post title was misleading!

I will give these ideas a shot! Thank you both :slight_smile:

Robin2:
To identify a wire it must have some identifiable characteristic and one way to do that is with resistors, Suppose you have the wires organised like this (when I say "Red Wire" I mean one end of the red wire etc.)

Arduino GND ---- Red Wire ---- 10k resistor --- Green Wire ---- 10k resistor ---- Blue wire --- Arduino 5v

Now, if you connect the other ends of the three wires to any of the analog pins and use analogRead() it will show 0 for the red wire, 1023 for the blue wire and 512 (approx) for the green wire.

...R

This worked perfectly!!! Thank you!! I'm building an escape room style box and this is intended to be one of the puzzles :slight_smile: