Advertisement
britneybeatey

Dice Prototype w/ Button

Jun 9th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. /*
  2. * Britney Beatey
  3. * Version 1
  4. * Dice Prototype
  5. */
  6. const int pinLed1 = 7;
  7. const int pinLed2 = 5;
  8. const int pinLed3 = 3;
  9. const int pinButt = 10;
  10. boolean buttDown = 0;
  11.  
  12. void setup() {
  13. // put your setup code here, to run once:
  14. pinMode (pinLed1, OUTPUT);
  15. pinMode (pinLed2, OUTPUT);
  16. pinMode (pinLed3, OUTPUT);
  17. pinMode (pinButt, INPUT);
  18.  
  19. Serial.begin (9600);
  20.  
  21. digitalWrite (pinLed1, HIGH);
  22. digitalWrite (pinLed2, HIGH);
  23. digitalWrite (pinLed3, HIGH);
  24. delay (500);
  25. digitalWrite (pinLed1, LOW);
  26. digitalWrite (pinLed2, LOW);
  27. digitalWrite (pinLed3, LOW);
  28. }
  29.  
  30. void loop() {
  31. // put your main code here, to run repeatedly:
  32. Serial.print (digitalRead(pinButt));
  33. Serial.print (digitalRead(buttDown));
  34.  
  35. if (buttDown == 1)
  36. {
  37. digitalWrite (pinLed1, HIGH);
  38. digitalWrite (pinLed2, HIGH);
  39. digitalWrite (pinLed3, HIGH);
  40. }
  41. else
  42. {
  43. digitalWrite (pinLed1, LOW);
  44. digitalWrite (pinLed2, LOW);
  45. digitalWrite (pinLed3, LOW);
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement