Hello. I'm new to the forum.
I am trying to check a digital input within a while loop. It just gets ignored, it seems.
I am communicating wirelessly between two Arduino Unos using 433MHz receiver/transmitter and HT12D decoder and HT12E encoder respectively. There are 4 data bits for passing data back and forth. It's working splendidly except for this one last hurdle of one Uno being able to stop the other's LED cycle.
Here is the function in question below. I'd like to include an image of the schematic, in case anyone's interested but don't see a way to do it.
void turn_on_display() {
int period = 2000;
unsigned long time_now = 0;
if (buzzer_ID_read_0 == brain_ID_sent_0 && buzzer_ID_read_1 == brain_ID_sent_1 &&
buzzer_ID_read_2 == brain_ID_sent_2 && buzzer_ID_read_0 == brain_ID_sent_0)
{
//compare IDs of original requestin box with answering box
buzzer_ID_read_0 = digitalRead(pin2);
buzzer_ID_read_1 = digitalRead(pin3);
buzzer_ID_read_2 = digitalRead(pin4);
brain_ID_sent_0 = digitalRead(pin10);
brain_ID_sent_1 = digitalRead(pin11);
brain_ID_sent_2 = digitalRead(pin12);
//turn off all pixels, white
for( int i = 0; i < numPixels; i++ )
{
strip.setPixelColor(i, r, g, b);
strip.show();// show all pixels
}
//keep leds on for period
time_now = millis();
while(millis() < time_now + period)
{
//check for led shutoff signal
if(digitalRead(led_on_off_bit) == 0)
{
strip.clear();
strip.show();
break;// exit loop
}
}
}
//clear variables
buzzer_ID_read_0 = 0;
buzzer_ID_read_1 = 0;
buzzer_ID_read_2 = 0;
brain_ID_sent_0 = 0;
brain_ID_sent_1 = 0;
brain_ID_sent_2 = 0;
strip.clear();
strip.show();
delay(5000);//delay for locking out other buzzers
}