britneybeatey

Learning Digital Inputs

Jun 7th, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. /* Britney Beatey
  2. * 6/7/2017
  3. * Version 1
  4. * Learning digital inputs
  5. */
  6.  
  7. const int pinButton = 2;
  8. const int pinLed = 7;
  9. boolean ledOn = 0;
  10.  
  11. void setup()
  12. {
  13. // put your setup code here, to run once:
  14. pinMode (pinButton, INPUT);
  15. pinMode (pinLed, OUTPUT);
  16. Serial.begin (9600);
  17. digitalWrite (pinLed, HIGH);
  18. delay (100);
  19. digitalWrite (pinLed, LOW);
  20.  
  21. }
  22.  
  23. void loop() {
  24. // put your main code here, to run repeatedly:
  25.  
  26. ledOn = digitalRead (pinButton);
  27.  
  28. if(ledOn == 1)
  29. {
  30. digitalWrite (pinLed, HIGH);
  31. }
  32. else
  33. {
  34. digitalWrite (pinLed, LOW);
  35. }
  36. }
Add Comment
Please, Sign In to add comment