Project showcase
Wake Up Timer

Wake Up Timer

I sleep a lot. For this, I wanted to make a timer. I want to sleep just four hours. Life is very short!

  • 4 views
  • 0 comments
  • 1 respect

Components and supplies

About this project

I read a book. And I like it. book's name is "ONLY FOOLS SLEEP 8 HOUR" (I am from Turkey I translated Book's name so orginal name is "Sadece aptallar 8 saat uyur. "). Book briefly tells us to sleep 4 hours. and I wanted 4 hour sleep. I made this project for this. Meanwhile I normally sleep around 10 hours :((((

SOME PICS...

STEP 1 :

STEP 2

Code

You can see my arduino codeArduino
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSerif9pt7b.h>
#include<Servo.h>
Servo motor; 
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

#define OLED_ADDR       0x3C
#define COUNTDOWN_TIME  14401000ul //4hour

char
    szString[20];
byte
    mins, secs;
        
unsigned long
    timeTemp,
    timeNow,
    timeStart,
    timeElapsed,
    timeLeft;    



void setup() 
{
    // initialize and clear display
    display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
    display.clearDisplay();
    display.setTextSize(1);
    display.setTextColor(WHITE);
motor.attach(2); // Servo motorun data pinini arduino 3 numaralı 
        motor.write(0);
        delay(1000);
    Serial.begin(9600);
    timeStart = millis();
    mins = 1;
    secs = 1;

}//setup

void DoCountdown()
{
    static unsigned long
        lastTimeNow = 0;
    static byte
        lastsecs = 1;
        
    timeNow = millis();
    timeElapsed = timeNow - timeStart;
    
    if( mins == 0 && secs == 0 )
        return;
        
    timeLeft = COUNTDOWN_TIME - timeElapsed;

    mins = (byte)(timeLeft / 60000ul);
    timeTemp = timeLeft - (mins * 60000);
    secs = (byte)(timeTemp / 1000ul);
    timeTemp = timeTemp - (secs * 1000ul);

    if( mins == 0 && secs == 0 )
    {
      motor.attach(2);
        sprintf( szString, "**WakeUp**" );
        Serial.println( szString );
        display.setCursor( 44, 30 );
        display.print( szString );
        display.display();
        motor.write(180);
        delay(1000);
  
         
    }//if
    else if( secs != lastsecs )
    {
        lastsecs = secs;
        sprintf( szString, "%02d:%02d", mins, secs );
        Serial.println( szString );
        //
        display.setCursor( 50, 30 );
        display.print( szString );
        display.display();


    }//if
  display.clearDisplay();
            motor.attach(3);

}//DoCountdown

void loop() 
{
    DoCountdown();

}//loop

Schematics

untitled_vjLqqMpyyS.png
ALERT !!
a4 and a5 cables maybe false location
Untitled vjlqqmpyys

Comments

Similar projects you might like

Morse Code Kitchen Timer

Project showcase by oklima

  • 1,537 views
  • 0 comments
  • 8 respects

Stopwatch and Lap Timer with Arduino

Project in progress by LAGSILVA

  • 18,434 views
  • 14 comments
  • 37 respects

Retro 1980s LED Clock/Count Up Timer

Project in progress by randtekk

  • 3,689 views
  • 4 comments
  • 17 respects

Lapsed Time Timer

Project showcase by Bobby

  • 968 views
  • 1 comment
  • 1 respect

Retro View Timer

Project tutorial by yilmazyurdakul

  • 885 views
  • 1 comment
  • 2 respects

Alarm Clock and Timer Working Standalone

Project showcase by ozyRonald

  • 9,794 views
  • 10 comments
  • 12 respects
Add projectSign up / Login