I am working on a project but am having some trouble with one part of it. I have 2 Nano's communicating via NRF24 modules. One module is a master with 6 switches and the other is a slave with 6 LEDs.
The code works no problem sending an array from the master to the slave and turning the LED's on and off. My problem comes in when I'm trying to use analogRead to conditionally control each of the corresponding LEDs (using a pot to simulate a current sensor). When the pot value gets above a certain level, the LED turns off.
Maybe I'm trying to do this the hard way, is there I way I can just bypass the entire array and pull the pin low?
this line confuses me. IS button_states[1] holding a pin number or a reading? analogRead expects a pin number and will read from that pin. Is the other nano telling you which pin to read?
digitalWrite(led_pins[0],button_states[0]);}
Here on the very next line you are using that same array as a button state and not a pin.
The goal is for a value over say, 500 on the first analog input pin to turn the first LED pin low. Is it possible to place the analog values in an array then call the array in a single if-else?
normal led function* [/quote] You have to place this if loop within for loop so it will be something like this: ```
*for(x=0;x<TotalLengthofArray;x++){
if(analog array [x] > specified value)
digitalWrite(led out array low)
else
normal led function
}*