Advertisement
andretafta

LED + Switch Button

Oct 16th, 2023
1,022
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const int pinOFswitch = 3;  
  2. const int LED = 8;  
  3. void setup( ) {  
  4.   pinMode(pinOFswitch, INPUT);  
  5.   pinMode(LED, OUTPUT);  
  6. }  
  7. void loop( )  
  8. {  
  9.   int ValueOFswitch;  
  10.   ValueOFswitch = digitalRead(pinOFswitch);  
  11.   if (ValueOFswitch == HIGH)  
  12.   {  
  13.     digitalWrite(LED, HIGH);  
  14.     delay(500);  
  15.   }  
  16.    
  17.   else  
  18.   {  
  19.     digitalWrite(LED, LOW);  
  20.     delay(500);  
  21.   }  
  22. }  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement