giovedì 20 novembre 2014

Delay 1

  /* Mentre BUTTON1
         è a livello HIGH per 10 sec. tutto il 
         LOOP è bloccato, infatti BUTTON2
         non riesce ad accendere LED2
      
      */
      
      const int BUTTON1 = 2;     
      const int LED1 =  12;     
      int buttonState1 = 0;       
      
      const int BUTTON2 = 3;     
      const int LED2 =  13;     
      int buttonState2 = 0;  
      
      long pMillis = 0;  
      long interval = 10000;  
      void setup()
      
           { pinMode(BUTTON1, INPUT);
             pinMode(BUTTON2, INPUT); 
             pinMode(LED1,   OUTPUT);      
             pinMode(LED2,   OUTPUT); }
      
      void loop(){
      
  buttonState1 = digitalRead(BUTTON1);
           if ( buttonState1 == HIGH)
               { digitalWrite(LED1, HIGH); 
                  delay (10000);           } 
          else { digitalWrite(LED1, LOW);  }
                       
  buttonState2 = digitalRead(BUTTON2);
            if ( buttonState2 == HIGH)
               { digitalWrite(LED2, HIGH); } 
          else { digitalWrite(LED2, LOW);  }
      }

Nessun commento:

Posta un commento