Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int buttonPin = 2;
- const int ledPin2 = 4;
- int count = 0;
- bool lastButtonState;
- int buttonState = 0;
- void setup() {
- pinMode(ledPin2, OUTPUT);
- pinMode(buttonPin, INPUT);
- }
- void loop() {
- buttonState = digitalRead(buttonPin);
- if (buttonState == HIGH && lastButtonState == LOW) {
- lastButtonState = buttonState;
- count++;
- }
- else {
- lastButtonState = buttonState;
- digitalWrite(ledPin2, LOW); }
- if (count >= 4) {
- count = 0; }
- if (count == 1) {
- digitalWrite(ledPin2, LOW); }
- else {
- digitalWrite(ledPin2, LOW);}
- if (count == 2) {
- digitalWrite(ledPin2,HIGH);
- delay(1000);
- digitalWrite(ledPin2,LOW); }
- else {
- digitalWrite(ledPin2, LOW);
- }
- if (count == 3) {
- digitalWrite(ledPin2, HIGH); }
- else {
- digitalWrite(ledPin2, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement