Hello guys,
In my project I am doing a board game, where it has a hall effect sensor under each cell with a RGB led. The game is basically to move the magnet from a start point (red led) to an end point (green led). The rest of the leds are off at the beginning, and whenever a magnet passes on the sensor which is next to the relevant led, it turns that led to be red. a player wins, if he reaches the end point (green led).
I am using a firestore database in order to load levels each time a player completes one (load pins colors from there).
I finished everything with the code, but I am facing this huge problem where some leds would still be on (red) when a player goes to the next level (while they are not supposed to be according to the data that I am retrieving). Apparently, the sensors' states are not resetting each level (even though I manually put state = 0, in the code after each level), since the leds are turned on depending on the sensor state.
More to that, if I edit the sketch and upload it back to the Arduino, it also saves states from previous sketch even though it's like I am resetting the Arduino (by uploading new code to its microcontroller).
I am using Arduino Mega with a NodeMCU for retrieving data and sending the data to Arduino with I2C. Also using a 16 channel analog multiplexer(74HC4067) for the the sensors.
The magnet I'm using is kind of crap (one of fridge magnets), but still this should not affect the sensors reset. (as when I turn on the Arduino, it kinda randomly chooses leds and light them red, because it seems that it reads its sensor as HIGH or something.
the code is kinda long, but my question is how do I turn off the sensors or reset them when I startup the Arduino (or reset it, or move on next level).
I am out of ideas here, because I didn't only search the whole internet. But I've tried every possible thing!!
I appreciate any help,
Thanks in advance