//uint32_t last_toggle = 1000;
#define STATUS_LED_ONE 4
#define STATUS_LED_TWO 5
// This is an array the last time a pin was toggled
// 0x0 - pin 0 delay
// 0x1 - pin 1 delay
int32_t last_toggle_array[14];
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN, OUTPUT);
pinMode(STATUS_LED_ONE, OUTPUT);
pinMode(STATUS_LED_TWO, OUTPUT);
last_toggle_array[STATUS_LED_ONE] = 200;
last_toggle_array[STATUS_LED_TWO] = 300;
}
void non_blocking_blink(uint8_t pin)
{
int32_t now = millis();
// fill in the code here to blink based on the current time
// and the last time since the previous blink.
// Hint: Use the last_toggle_array
if(now - last_toggle_array[pin] > 500 )
{
if(digitalRead(pin) == LOW )
digitalWrite(pin, HIGH);
else
digitalWrite(pin, LOW);
last_toggle_array[pin] = now;
}
}
void loop() {
// put your main code here, to run repeatedly:
non_blocking_blink(STATUS_LED_ONE);
non_blocking_blink(STATUS_LED_TWO);
non_blocking_blink(LED_BUILTIN);
}