Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Ticker.h>
- #define SIGNAL_PIN D2
- Ticker flipper;
- void setup()
- {
- Serial.begin(9600);
- pinMode(SIGNAL_PIN, INPUT);
- digitalWrite (SIGNAL_PIN, LOW);
- }
- void flip(){
- Serial.println("From callback");
- digitalWrite (SIGNAL_PIN, HIGH);
- }
- void loop() {
- if(digitalRead(SIGNAL_PIN)==HIGH) {
- Serial.println("Movement detected.");
- flipper.attach(1, flip);
- } else {
- Serial.println("Did not detect movement.");
- flipper.detach();
- }
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement