-
-
Save anonymous/df522b90b4386103faaf52c3e3ab34d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int buttonPin = 2; // the number of the pushbutton pin | |
const int staubi = 13; // the number of the LED pin | |
const int nebel = 12; // the number of the pushbutton pin | |
const int vent1 = 6; | |
const int vent2 = 7; | |
volatile int buttonState = 0; // variable for reading the pushbutton status | |
void setup() { | |
pinMode(staubi, OUTPUT); | |
pinMode(buttonPin, INPUT); | |
pinMode(vent1, OUTPUT); | |
pinMode(vent2, OUTPUT); | |
pinMode(nebel, OUTPUT); | |
attachInterrupt(0, pin_ISR, CHANGE); | |
} | |
void pin_ISR() { | |
buttonState = digitalRead(buttonPin); | |
digitalWrite(staubi, buttonState); | |
digitalWrite(nebel, buttonState); | |
} | |
void loop() { | |
digitalWrite(vent1, HIGH); // Vent1 an | |
delay(15000); // 15s einatmen | |
digitalWrite(vent1, LOW); // Vent1 aus | |
delay(3000); // Pause 3s | |
digitalWrite(vent2, HIGH); // Vent2 an | |
delay(15000); // 15s ausatmen | |
digitalWrite(vent2, LOW); // Vent2 aus | |
delay(3000); // Pause 3s | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to pull pin 13 up (or down) with a resistor and let the pushbutton switch pull the input down (or up) when it is pressed.