hi everyone, i am just a very beginner in arduino (only 3 days...!!!) and i speak a very poor english ( only 3 days too... )
i have a little project which is the following. during a circus show i need some "TOP" to send the light "go"on my lighting desk, but sometimes i have to see some people to send the GO, but as you know, almost of time it is black in the venue, and so i can't see the people if they are in ready position to send the GO.. so here is my idea. i am going to install some push button (kind of switch) in all the place i can not see the people, and when they are ready ,they push the button, and that give me a signal of the a blinking led.
so, do to that, and start in arduino, i baught the massimo banzi book " geting started with arduino" and i use the first workshop to make a LED switch ON and keep it ON after one push on the button. that work fine but my problem is: i would like the signal stay active in blinking mode during 3 second then switch off, without push an other time on the button. i tried to add some "delay(3000); { digitalwrite(LED, LOW) } after the if/ else content, but it doesn't work.. i guess it is a very simple thing to do , but i think i don't have the programming vibe...!!!
so this is the code where i am.. if someone can tell me what is the function to stop the loop mode, in oder to get only one blinking signal of 3 second, then wait for the next "push button" to get the signal 3 second, and so on....
#define LED 11 // patte pour la led en 12
#define BUTTON 6 // patte entrée pour le switch
int val = 0; // val sauve etat entree switch
int old_val = 0; // contient précendente valeur de val
int state = 0; // 0 = led eteinte , 1 = led allumee
void setup() {
pinMode(LED, OUTPUT); // DEL sur sortie
pinMode(BUTTON, INPUT); // bouton en entrée
}
void loop() {
val = digitalRead(BUTTON); // lit et sauve l'entree du switch
if ((val == HIGH) && (old_val == LOW)){
state = 1 - state;
delay(200);
}
old_val = val; // sauve ancienne valeur
if (state == 1) {
digitalWrite(LED, HIGH); // allume led
delay(100);
digitalWrite(LED, LOW); // eteint led
delay(100);
}
else {
digitalWrite(LED, LOW);
}
delay(3000) {
digitalWrite(LED, LOW);
}
}