I'm making a laser maze for an event, and I've been trying to work this out in my head...
void section1()
{
delay(100);// delay to make sure it's a real trigger
laserstate1 = digitalRead(lasersens1);
if(laserstate1 == 1)// if it is a trigger, if it isn't make sure the lights are off and go back to the loop
{
leds[0] = CRGB (255,255,255);
leds[1] = CRGB (255,255,255);
leds[2] = CRGB (255,255,255);//Trigger lights to illuminate those who tripped it
leds[3] = CRGB (255,255,255);
leds[4] = CRGB (255,255,255);
FastLED.show();
//resetButtonState = digitalRead(resetButton);
while(digitalRead(resetButton) == 0 || digitalRead(lasersens1) == 1) {//require the person to leave then press a button to reset the lights
//resetButtonState = digitalRead(resetButton);
}
}
leds[0] = CRGB (0,0,0);
leds[1] = CRGB (0,0,0);
leds[2] = CRGB (0,0,0);
leds[3] = CRGB (0,0,0);
leds[4] = CRGB (0,0,0);
FastLED.show();
}
void loop() {
while (1)
{
laserstate1 = digitalRead(lasersens1);//Wait for a laser to be blocked
if(laserstate1 == 1)
{
section1(); //Trigger the section sequence
}
}
}
There would be more lasers, hoping to be in the neighborhood of 10-20
My question is would there be an advantage to running a timer instead of the delay in "section1"?
I know there theoretically there would be but when it's only 100ms it doesn't feel necessary.
It should be noted that each lasersens wouldn't trip its own section but rather a group of "lasersens" would make a section, and each trigger a singular set of lights.
The only other thing would be an addition of a kill switch they could find and press to deactivate the system. for x amount of time.