Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://github.com/rocketscream/Low-Power
- #include <LowPower.h> //the library for the low power
- #include <Wire.h> //i2c library for display
- #include <Adafruit_SSD1306.h> //adafruit display library
- #define OLED_RESET 4 //required by the adafruit library
- Adafruit_SSD1306 display(OLED_RESET); //set up the display
- void setup() {
- Serial.begin(9600); //serial comms for debugging
- pinMode(13,OUTPUT); //set built in LED for output
- digitalWrite(13,LOW); //turn off LED
- display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //start the display
- display.display(); //display the buffer data
- display.clearDisplay(); //clear the display
- }
- void loop() {
- digitalWrite(13,HIGH); //turn on led
- display.setTextSize(2); //setup data for display
- display.setTextColor(WHITE); //setup data for display
- display.setCursor(0,0); //setup data for display
- display.clearDisplay(); //setup data for display
- display.println("Arduino:- I am going for a Nap"); //put nap message in buffer
- display.display(); //display the buffer data
- delay(2000); //have a quick smoke
- digitalWrite(13,LOW); //turn LED off
- LowPower.idle(SLEEP_8S, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_OFF,
- SPI_OFF, USART0_OFF, TWI_OFF); //sleepy time
- display.clearDisplay(); //setup data for display
- display.setCursor(0,0); //setup data for display
- display.println("Arduino:- Hey I just Woke up"); //put wake up message in buffer
- Serial.println("");
- display.display(); //display buffer data
- delay(2000); //finish that smoke
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement