Created
June 23, 2015 13:36
-
-
Save michaelsarduino/6b72c9bd1b5df0e7160d to your computer and use it in GitHub Desktop.
Stand-by-Modus für den Arduino Sketch1
This file contains hidden or 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
#include <avr/sleep.h> | |
#include <avr/power.h> //nachladen der benoetigen Bibliotheken | |
void setup() { | |
pinMode(13, OUTPUT); //definieren von Pin 13 als OUTPUT | |
attachInterrupt(0, interrupt, RISING); //festlegen des Interrupts an Pin 2 | |
} | |
void loop() { | |
digitalWrite(13, HIGH); | |
delay(3000); | |
digitalWrite(13, LOW); //3 Sekunden LED leuchten | |
enterSleep(); //starten der enterSleep() Funktion | |
} | |
void interrupt() { | |
//leere Interruptfunktion | |
} | |
void enterSleep(){ | |
set_sleep_mode(SLEEP_MODE_PWR_DOWN); //festlegen des Schlafmoduses | |
sleep_enable(); //ermoeglichen der angegebenen Schlaffunktion | |
sleep_mode(); //starten der Schlaffunktion | |
//hier geht es nach dem Interrupt weiter | |
sleep_disable(); //deaktivieren der Schlaffunktion | |
power_all_enable(); //reaktivieren aller Chips/Funktionen | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment