Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int gLED = 3; //Sets ints for the output pins
- int rLED = 2;
- int button = 4;
- void setup() {
- // put your setup code here, to run once:
- pinMode (gLED, OUTPUT); //defines pin modes
- pinMode (rLED, OUTPUT); //defines pin modes
- pinMode (button, INPUT); //defines pin modes
- Serial.begin(9600);
- //Does a little im ready Dance
- digitalWrite(gLED, HIGH);
- digitalWrite(rLED, HIGH);
- delay(1000);
- digitalWrite(gLED, LOW);
- digitalWrite(rLED, LOW);
- delay(1000);
- digitalWrite(gLED, HIGH);
- digitalWrite(rLED, HIGH);
- delay(1000);
- digitalWrite(gLED, LOW);
- digitalWrite(rLED, LOW);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- int buttonState = digitalRead(button); //sets int of the variable button state based on the button input
- Serial.println(buttonState);
- if (buttonState >= 1){ //if the button is pressed then red led on
- digitalWrite(rLED, HIGH);
- int rON = YES; //Trying to tell the int that if the LED is set HIGH then set rON to YES
- }
- if (buttonState < 1){ //if button not pressed then red led off
- digitalWrite(rLED, LOW);
- }
- if (rON = YES){ //trying to make the green LED come on IF the red LED is on based on the Int set above.
- digitalWrite(gLED = HIGH);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement