Advertisement
iyera20

Second Program: LED With Button Variation 1

Jun 7th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. /*
  2. * Atiriya Iyer
  3. * Veriation 1
  4. * Learning Digital Inputs
  5. */
  6. const int pinLED = 7;
  7. const int pinButton = 2;
  8. int readValue = 0;
  9.  
  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. digitalWrite(pinLED, HIGH);
  30. }
  31.  
  32. else
  33. {
  34. digitalWrite(pinLED, LOW);
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement