Hey guys, I'm working on making a puzzle for an escape room using an arduino and I'm having trouble figuring out the best way to do it.
The basic theory is that people have to plug in up to 9 items into specific sockets (I'm using Banana plugs). The arduino should be able to identify each of the 10 unique objects, and be able to open a maglock when items are plugged in their correct spaces.
I know the programming part and the mag lock wiring. Just not sure what the best way to have an arduino identify objects.
Simplest option I found was using a single resistor in the object and just making an ohm meter circuit,
identifying each item by it's resistance. I ran into trouble when using multiple objects as the resistors would affect each other. Is there way for me to wire it to have the unknown resistors coming. Otherwise are there easier ways to identify objects plugged into a circuit.
Use 4 pins on the arduino (+ ground) to make a binary-coded decimal or hexadecimal identifier. That is, each item would plug into a 5 pin connector, MIDI connectors very common, easy to find. Each item would make 1, 2, 3 or all connections to ground, giving 16 combinations. Simply check High or LOW. You will want to use external 10K resistors to pull the pins HIGH when nothing is inserted.
You could match each resistor up with an equal resistor. Then use an analog switch to multiplex each measurement point into one pin on the Arduino. Then simply measure using analogRead().
When each is placed in the correct hole, the voltage would then be Vcc/2, minimizing errors.
If you use an analog multiplexer that uses something like SPI or I2C, you use fewer pins. Even using binary, a 9 multiplexer circuit only requires 4 pins.
Perehama:
Use 4 pins on the arduino (+ ground) to make a binary-coded decimal or hexadecimal identifier. That is, each item would plug into a 5 pin connector, MIDI connectors very common, easy to find. Each item would make 1, 2, 3 or all connections to ground, giving 16 combinations. Simply check High or LOW. You will want to use external 10K resistors to pull the pins HIGH when nothing is inserted.
traitor:
Would I have to use 4 pins for every socket?
I think I get what you are suggesting... You need all 9 keys connected at the same time to open the escape room. You want some way to connect 9 keys while insuring electronically that they are the right key. In that case, yes, you would need 4 pins for each key. However, if you made it so that when a key was inserted, it lit the appropriate LED, that key could then be removed, but still counted. This would require 4 pins, 1 socket, and 9 pins for LEDs.
Perehama:
I think I get what you are suggesting... You need all 9 keys connected at the same time to open the escape room. You want some way to connect 9 keys while insuring electronically that they are the right key. In that case, yes, you would need 4 pins for each key. However, if you made it so that when a key was inserted, it lit the appropriate LED, that key could then be removed, but still counted. This would require 4 pins, 1 socket, and 9 pins for LEDs.
Yes, I need all 9 sockets to be actively checking if they are the correct number plugged in.
Basically I have a 3x3 board with various math symbols in between
i.e.: [] + [] - []
x /
[] x [] - []
/
[] x [] / []
they are plugging numbers into the [] spots
when the correct numbers are there a door opens.
I should be able to daisy chain a bunch of shift registers probably to minimize the amount of pins used?
traitor:
Can you elaborate on the multiplexing, I've never used a multiplexer ever?
basic multiplexing, or otherwise known as not multiplexed, given 9 switches (buttons etc.) is 9 GPIO tied to one side of each switch and the other side tied to a common, either V+ or ground. pull up or pull down resistors pull the signal in the opposite direction from the switch, so if the switch is made the signal goes low, if open, the signal remains high.
Now, we take that common at tie it to an output, so that the switch will only go low if the output is low... Now, we take 3 switches in parallel and do this with 1 output, then 3 others, using the same 3 inputs as the first, to a second output, then the last 3, same inputs, to a third. In code, we set the output low, then read the 3, then high, then set 2 low, read, high, set 3 low, read, high. This is multiplexing. so, instead of using 9 GPIO, we only use 6, but we are reading 3 switches at a time, so we are going slower. Relevant to your project, setting up 9 inputs and 4 outputs would give you the BCD you need, using only 13 GPIO.
Bizzare solution :
use 9 ds18b20, one assigned to each pin, and use the unique serial number to assign each sensor to pin. Little bit expensive, but just 9 pins used!
ilguargua:
Bizzare solution :
use 9 ds18b20, one assigned to each pin, and use the unique serial number to assign each sensor to pin. Little bit expensive, but just 9 pins used!
Ciao, Ale.
Brilliant!! a 24AA02UID-I/P is quite a bit cheaper, and all 9 can hang on the same I2C bus.
Perehama:
Brilliant!! a 24AA02UID-I/P is quite a bit cheaper, and all 9 can hang on the same I2C bus.
Umm, no ... and no!
ilguargua beat me to it - I wasn't looking at this thread.
The DS18B20 - a temperature sensor chip - is a "one wire bus" device which uses just two (or three) wires to connect, so you can connect it with a common jack and plug - either 3.5 mm or 6.5 mm - it will even fit in the shell of the plug so the plug could be on the end of a dummy plastic cord. I have been collecting them from used medical disposables (heated insufflation hoses).
The 2402 is completely different - it is an I2C device which always requires four pins to connect. You could use one of the four-way jack/ plugs used for earphone/ microphone sets on mobile phones, but not as convenient - or durable - as the two-pin connection.
Secondly, the OP wants to identify which device is plugged into which socket. We have been over this in a previous thread - as usual. So you need nine Arduino pins - one per socket, and nine instances of the "one wire bus" object.
This would be more difficult with I2C where you would be using the software implementation for each outlet and two pins for each. The approach (or one option) previously discussed for this was to use a number of multiplexers (74HC4052) and the hardware I2C, but nine pins and the Dallas One Wire devices is far more straightforward.
Multiplexing is like connecting a rotary switch to your Arduino. In this case, 9 inputs go through a 9 way analog switch. Only one is connected to the output at a time. The Arduino tells the analog switch which one to connect, so it knows which one it is reading.
Then you are only using one analog input.
They normally come in binary multiples, so the next one up from 8 channels is 16. But they are not expensive for a project with modest needs like this one. Here is one on a breakout board for under $6 with free 2 day shipping if you have Prime: 16 Channel Analog MUX Multiplexer
Or use a Mega, which has 16 analog inputs. FYI, the Arduino only has one internal ADC input, it has an internal multiplexer.
Yes, 4 pins per connection, 2 to a common I2C bus, 1 to one of 3 "low-side" outputs, 1 to one of 3 "high-side" outputs, since the chip takes about 1mA to read. You use 6 GPIO to multiplex powering them to read them on a common bus. Unless you have a bunch laying around, 9 quarters is a lot cheaper than almost $20.
Paul__B:
Do you know about protection diodes on interface pins?
Yes, I know about protection diodes on interface pins. To multiplex VCC and VSS on each chip, without connecting VCC to ground or VSS to high, you add Schottky rectifiers on all 6 pins. In low quantities that does take up the price equal to or beyond the price of the temp sensor, and I already said that was a brilliant idea, but by the reel, they are less than a dime each. I admit that I hadn't fully thought it through, and I'm having to rework a half-cocked statement. That said, it's not impossible to do it with a UID IC. Personally, if this were my project, I would have done it the way I suggested in my first post, multiplexing 9 x 4 to give 16 possible UIDs on the 9 inputs. I think that approach avoids analog resistances, extra parts etc. I did think the temp sensor idea was a brilliant approach, and only threw the UID chip in because of cost. I agree with you that it's not as simple as the temp sensor.