Go Down

Topic: Arduino buzz wire game (Read 1 time) previous topic - next topic

lmy13

Hey i think this is where the delay is, in the code for the background animation
Code: [Select]
void loop()
{
val1 = digitalRead(BUTTON1); //read input value from button1
//check if there was a transition
if (val1 == HIGH) { //if we touch the start point
Serial.println ("1");
digitalWrite (LED, HIGH);
delay (100000);
}
if (val1 == LOW ) { //if nothing happens
digitalWrite ( LED, LOW);
}


I set the delay to (100000)...in order to play the whole animation... but it seems that I can't skip it once I press the 1st button I have to wait until it ends so we cant play a short scary animation in between(when the wire is touched) while the background animation is playing? is there any way we can interrupt the signal for about 2 seconds to play this short clip to scare people when they touch the wire and then continue playing the background animation again?

I found a thing called "hardware" interrupt could you explain this to me please :) does it mean I can interrupt the background animation when I press another button, can we use this?  can I use the second button to be the interrupt trigger ?
Will it be able to stop the first animation and play another one, then go back to that loop animation after the interrupt one is finished?


thank you again you've been a great help :)

Grumpy_Mike

Just never use delay.
Look at the blink without delay example built into the arduino PC software.
Interrupts are not going to help you with this problem, just get rid of the delay.

Go Up