Advertisement
iyera20

Second Program: LED With Button Variation 2

Jun 7th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. /*
  2. * Atiriya Iyer
  3. * Veriation 2
  4. * Learning Digital Inputs
  5. */
  6. const int pinLED = 7;
  7. const int pinButton = 2;
  8. int readValue = 0;
  9. boolean lightOn = 0;
  10. void setup() {
  11. // put your setup code here, to run once:
  12. pinMode (pinButton, INPUT);
  13. pinMode (pinLED, OUTPUT);
  14.  
  15. Serial.begin(9600);
  16.  
  17. digitalWrite(pinLED, HIGH);
  18. delay(50);
  19. digitalWrite(pinLED, LOW);
  20.  
  21. }
  22.  
  23. void loop() {
  24. // put your main code here, to run repeatedly:
  25. readValue= digitalRead(pinButton);
  26.  
  27. if(readValue==1)
  28. {
  29. lightOn= !lightOn;
  30. digitalWrite(pinLED, lightOn);
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement