Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * this is the blink program
- * Author: Mason
- * 9/1/17
- * Version 3
- */
- const int LedPinRed = 11;
- const int LedPinGreen = 10;
- const int Button = 2;
- boolean ReadValue;
- boolean LastValue;
- int counter = 0;
- void setup()
- {
- pinMode (LedPinRed, OUTPUT);
- pinMode (LedPinGreen, OUTPUT);
- pinMode (Button, INPUT);
- Serial.begin (9600);
- }
- boolean debounce(boolean last)
- {
- boolean current = digitalRead(Button);
- if (last != current)
- {
- delay(5);
- current = digitalRead(Button);
- }
- return current;
- }
- void loop()
- {
- if (LastValue == LOW && ReadValue == HIGH);
- ReadValue = debounce (LastValue);
- {
- counter++;
- Serial.println (counter);
- }
- if (counter == 1 || counter == 4)
- {
- digitalWrite (LedPinRed, HIGH);
- digitalWrite (LedPinGreen, LOW);
- }
- if (counter == 2)
- {
- digitalWrite (LedPinRed, LOW);
- digitalWrite (LedPinGreen, HIGH);
- }
- if (counter == 3)
- {
- digitalWrite (LedPinRed, HIGH);
- digitalWrite (LedPinGreen, HIGH);
- }
- if (counter == 5)
- {
- digitalWrite (LedPinRed, LOW);
- digitalWrite (LedPinGreen, LOW);
- counter == 0;
- }
- LastValue = ReadValue;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement