Go Down

Topic: analogRead (Read 823 times) previous topic - next topic

Bapstack

I am trying to make a puzzle where I have 5 terminals on the left, and 5 terminals on the right, and I have 5 wires connecting them, each with a different resistor value.

To solve the puzzle, the correct 2 terminals must be connected with the correct wire. I'm trying to figure out a way to accomplish this and am struggling to do so.

My thought was to use 5 digital pins as the Vin for a voltage divider and then cycle through, turning each on and then off, but my thought processes so far have not worked out (downloading fritzing now to show what I've been attempting). How do I verify both that the correct two pins are connected AND that they are connected by the correct wire?

As an added complication, I'd like the correct solution to have two of the left terminals connect to a single terminal on the right, leaving one terminal disconnected.

larryd

More explanation please.

Refer to a schematic, not fritzing.


.
No technical PMs.
The last thing you did is where you should start looking.

Delta_G

Please, not Fritzing.  Those are really hard to see what's going on in.  Just draw it on paper and post a picture.  Anything is better than Fritzing. 
If at first you don't succeed, up - home - sudo - enter.

Bapstack

#3
Dec 07, 2017, 03:45 am Last Edit: Dec 07, 2017, 03:56 am by Bapstack
The 5 "jumper cables" are on the left, and the 10 terminals are on the right. Each terminal on the left needs to connect to a specific terminal on the right, using a specific jumper wire.

edit: Photo was too large, and the 5 minute rule is very unhelpful. It'd be nice if they'd let Newbies at least edit posts within the first 5 minutes.

Bapstack

#4
Dec 07, 2017, 03:58 am Last Edit: Dec 07, 2017, 04:03 am by Bapstack
My image keeps failing security checks?



edit: And now the image is not showing up in my post. I know how to use technology, promise. Link to the picture below.

https://imgur.com/Yu626CX

Delta_G

Try this thread http://forum.arduino.cc/index.php?topic=364156.0

It's a common enough issue that someone was nice enough to write up a how to. 

I think the security thing is even covered in there, but IIRC if you convert your image to .png you won't have any issues like that.
If at first you don't succeed, up - home - sudo - enter.

Bapstack



I'm just dumb. I posted the link to the Imgur page, not the picture itself. If this doesn't work and no picture is visible and I don't respond, assume I've jumped out the window.

Delta_G

#7
Dec 07, 2017, 04:17 am Last Edit: Dec 07, 2017, 04:18 am by Delta_G
You don't really even need the resistors.  Connect all the pins on the left to digital pins set as output and driven high.  Connect all the pins on the right to digital pins set as inputs with the internal pull-up resistors enabled.  Go through the output pins connected to the terminals on the left one at a time pulling them low.  Each time you pull one low, go read all the inputs on the right and whichever one is reading low is the one connected to the pin on the left that you just drove to low. 
If at first you don't succeed, up - home - sudo - enter.

Bapstack

You don't really even need the resistors.
Trouble is, for the solution to be correct, OR needs to be connected to RR with orange. So the specific jumper used matters. Hence the resistors.

larryd

#9
Dec 07, 2017, 04:27 am Last Edit: Dec 07, 2017, 04:28 am by larryd
Are you familiar with a voltage divider?

https://learn.sparkfun.com/tutorials/voltage-dividers  


No technical PMs.
The last thing you did is where you should start looking.

Delta_G

OK, that's easy then.  Same basic concept but analog inputs instead of digital.  Instead of digital inputs on the right you have analog inputs that are connected to the terminals and to 5V through some common value of resistor.  Now an unconnected pin will read 1023 as will a pin that is connected to one of the terminals on the left that is still driven high.  Just as above, you drive the pins on the left low one at a time.  All the analog inputs are going to read 1023 except the one that is connected to that terminal on the left that is driven low.  Same as before.  Only now, instead of reading low it will read some number that is characteristic of the particular resistor between the two terminals as that resistor and the one connected from the analog input to ground form a divider.  
If at first you don't succeed, up - home - sudo - enter.

Bapstack

Instead of digital inputs on the right you have analog inputs that are connected to the terminals and to 5V through some common value of resistor.
So each analog pin is connected to 5V through a common value resistor, but separately from the other analog pins, right? As in, I don't connect each analog pin directly to the others?

And thank you, this is what I couldn't wrap my head around. It didn't occur to me to use the 5V.

Delta_G

If you connected all the analog pins together they'd all read the same voltage and that would completely defeat you.  Right?
If at first you don't succeed, up - home - sudo - enter.

Bapstack

....yes. That would. Thanks again for your help.

larryd

#14
Dec 07, 2017, 05:05 am Last Edit: Dec 07, 2017, 05:06 am by larryd
No technical PMs.
The last thing you did is where you should start looking.

Go Up