I am currently working on building a “useless machine” with 8 switches (in case you’re wondering what I’m talking about, you can check it out here - YouTube) and on my ARDUINO UNO card I don’t have enough analogic inputs to plug all the switches. Thus, I thought of using a multiplexer 4051.
I came up with the idea of coding it the following way: Put my selected inputs switch from 000 to 001 then 010 to 111… and loop it all over again endlessly until the output reaches the logic state ‘1’ which means that one of the switches has been switched ON so I just have to get my selected inputs’ values back.
But here’s the tricky part: In order to know if another switch has been set ON, I need my loop to keep going on all the time. That’s why I thought that I need simultaneous loops: First, the loop I’ve previously mentioned allowing to “detect” anytime a switch is set ON. Secondly, a “big” loop which is here to loop all the functions for the whole program to run well (for instance, when the 7th switch is turned ON at the moment the rod is in position “switch1” then FUNCTION_1 comes into play and lowers the rod down before FUNCTION_2 forces it to move towards position “switch7”). I think I’ve read somewhere across the forum that it’s not doable, but there must be a way to sort it out differently. It’d be really appreciated if some of you had an idea to work it out
Thanks in advance