Hello. I'm having trouble reading the reed switch state with the Arduino Nano, the code compiles without any errors but when run it reads the reed switch state as open every time. Even an indirect short-circuit of pins on the multiplexer and an attempt to read it causes it not to recognize anything. The pin layout is well connected, I have no idea where the error is (probably in the code). Thank you for your help!
Oi! Did you read about posting code?
Help us help you.
Hi, @piotr2000
Welcome to the forum.
Please take note of @Idahowalker post, it will help immensly.
What are you multiplex ICs, and as you are switching gnd, do you have any pull-up resistors to pull the multiplexer input HIGH when the switch is open?
Did you start your coding with ONE multiplexer and get your hardware and software working?
If not, that might be a good start.
Thanks.. Tom..
hard to read schematic. could you provide a partial blow up showing the connections between the Arduino (?) and first device (?)
Did the OP try a simple circuit to see if the thing would work then add in all the other stuff in increments or did the OP just build the entire project all at once?
If you are using a 9V battery like this.
Don't.
I added pull-up resistors but still nothing. Even bypassing the reed switches and connecting GND directly to one of the channels, the reading is still incorrect, it looks like it doesn't see that something is connected.
Post an image of the project.
Did the OP ever get a simple circuit to work before creating the monster that does not work?
I built the whole system with the code in one day, I wrote the code that in theory was supposed to work. I use the power adapter for power.
I created systems with one multiplexer and they worked, this is the first time where 4 multiplexers are connected
Was it tested as it was built?
Could you try to build a simple circuit using only 1 plexer and a few reed switches?
Get the simple working first.
If you get one multiplexer working add in one more multiplexer. Not 3 or 4 or 5 or 6. Just one more.
post an image of your project of 2 plxers all wired up and not working.
Problem, bread board power rail split:
Solution, bread board power rail split:
You have added in filtering caps to each plexer, right?
You are really feeding 12V to the Uno? I'd go with 7Vin. Lot less power wasted as heat that way.
if your not going to provide a more detailed drawing as requested, can you post the code that you say works reliably with one multiplexer and explain the additional multiplexer connections?
without know what the part is, i assume there is an enable/select pin that needs to be pulled low to access each multiplexer and that some clock pin is pulsed followed by a read of a data pin. not sure i'm seeing that in your reed_switch_status()
The schematic is blurry when enlarged.
Looks like each analog multiplex is tied to the same CS pin?
The schematic shows Tx,Rx,D0,D3, D4, and D5 all shorted together. Why short those pins together?
Hi,
Write code that only reads ONE switch, hard code it, don't use arrays.
Write the code so that you address one switch and see if it works, try one switch in each bank.
That way you will know your hardware is most possibly working.
What multiplex IC are you using?
Tom..
Multiplexer CD74HC4067
There are much easier ways of reading 64 reed switches.
If you explain what the purpose of the project is, we can suggest simpler ways to read them. For example by connecting them as a matrix.
Will more than one reed switch be activated at the same time? If so, you would need to add a small diode in series with each reed switch, but the circuit would still be simpler overall.
Did you just only connect 2 plexors together? Did it work? Post the image of your project all wired up with2 plexers and not working.
The aim of the project is to read the position of the magnets on an 8x8 board. After moving the magnet and pressing the button, the program is to start the multiplexers and send information about the new current status of all 64 reed switches
if it's a chess board (see comment on 1st line of code), multiple switches will be closed at the same time
please post a readable image showing the connections between the arduino and a multiplexer