-
Arduino Sleep & Wake up아두이노 2017. 10. 30. 17:17
아두이노 Wake up & Sleep
#include <Wire.h> #include <avr/sleep.h> // I2C bus address declarations: #define DS1337_I2C_ADDRESS 0x68 // DS1337 void wake () { // cancel sleep as a precaution sleep_disable(); // must do this as the pin will probably stay low for a while detachInterrupt (0); } void setup() { // initialize ouptut pins pinMode(7, OUTPUT); // initialize I2C bus Wire.begin(); // initialize RTC Wire.beginTransmission(DS1337_I2C_ADDRESS); // Open I2C line in write mode Wire.write((byte)0x0E); // Set the register pointer Wire.write((byte)0x00); // Set the status register Wire.endTransmission(); // End write mode } void loop() { digitalWrite(7, HIGH); digitalWrite(7, LOW); set_sleep_mode (SLEEP_MODE_PWR_DOWN); sleep_enable(); // Do not interrupt before we go to sleep, or the // ISR will detach interrupts and we won't wake. noInterrupts (); // will be called when pin D2 goes low attachInterrupt (0, wake, LOW); interrupts(); sleep_cpu(); }
'아두이노' 카테고리의 다른 글
IC-Station MFRC522 Hack custom firmware (0) 2018.08.11 아두이노 부트로드 굽기 (0) 2017.11.02 AVRDUDE 명령어 사용법 (0) 2017.11.01 AVR tip (0) 2017.10.26 HS-08 아두이노 연결 (0) 2017.10.13