Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. int gLED = 3; //Sets ints for the output pins
  2. int rLED = 2;
  3. int button = 4;
  4.  
  5. void setup() {
  6. // put your setup code here, to run once:
  7. pinMode (gLED, OUTPUT); //defines pin modes
  8. pinMode (rLED, OUTPUT); //defines pin modes
  9. pinMode (button, INPUT); //defines pin modes
  10. Serial.begin(9600);
  11. //Does a little im ready Dance
  12. digitalWrite(gLED, HIGH);
  13. digitalWrite(rLED, HIGH);
  14. delay(1000);
  15. digitalWrite(gLED, LOW);
  16. digitalWrite(rLED, LOW);
  17. delay(1000);
  18. digitalWrite(gLED, HIGH);
  19. digitalWrite(rLED, HIGH);
  20. delay(1000);
  21. digitalWrite(gLED, LOW);
  22. digitalWrite(rLED, LOW);
  23. }
  24.  
  25. void loop() {
  26. // put your main code here, to run repeatedly:
  27. int buttonState = digitalRead(button); //sets int of the variable button state based on the button input
  28. Serial.println(buttonState);
  29. if (buttonState >= 1){ //if the button is pressed then red led on
  30. digitalWrite(rLED, HIGH);
  31. int rON = YES; //Trying to tell the int that if the LED is set HIGH then set rON to YES
  32. }
  33. if (buttonState < 1){ //if button not pressed then red led off
  34. digitalWrite(rLED, LOW);
  35. }
  36. if (rON = YES){ //trying to make the green LED come on IF the red LED is on based on the Int set above.
  37. digitalWrite(gLED = HIGH);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement