Project showcase
Arduino OLED Word Clock

Arduino OLED Word Clock © GPL3+

A word clock using an OLED display.

  • 5,479 views
  • 1 comment
  • 11 respects

Components and supplies

Apps and online services

About this project

My goal was to make a word clock. I tried with the shift registers and LED strips without success. Decided to go with something much simpler, an OLED display. This clock uses an Arduino nano, a DS1307 RTC, and an 091 128 X 32 OLED display. Circuit is simple as is code. Simple wiring Nano a4 to SDA, a5 to SCL, ground and 5v to both RTC and display.

Code

oled word clockArduino
run RTCLib ds1307 to set time on rtc before using with display
//OLED Word Clock


#include <Wire.h>  
#include"RTClib.h"
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 32)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
// Display output
#define MINUTES
#define MTEN 	
#define HALF	
#define PAST	
#define THREE	
#define ITIS	
#define TWENTY	
#define TO	  
#define TWO	   
#define SIX	 
#define TWELVE	
#define HFIVE	
#define SEVEN	
#define OCLOCK	
#define ONE	   
#define QUARTER	
#define EIGHT	
#define MFIVE	
#define ARDUINO	
#define ELEVEN	
#define HTEN	
#define NINE	
#define FOUR
#define RBK	    
int hour=0, minute=0, second=0;
static unsigned long msTick =0;  // the number of Millisecond Ticks since we last 
// incremented the second counter
int  selftestmode;          // 1 = in self test - flash display
 char Display1=0, Display2=0, Display3=0;
                  
// RTC DEFINE-
RTC_DS1307 RTC ;
void setup()
{
  Serial.begin(9600);   // setup the serial port to 9600 baud
  Wire.begin();
  RTC.begin();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
  // init done
  //Clear the buffer.
  display.clearDisplay();
  //draw scrolling text
  testscrolltext();
  delay(2);
  display.clearDisplay();
    if ( RTC.isrunning()) {
      DateTime now = RTC.now();
       display.clearDisplay();
  }
      
  DateTime now = RTC.now();
    msTick=millis();      // Initialise the msTick counter
  if ( RTC.isrunning() ) {
    // Get the current time and date from the RTC chip 
    second=now.second();     
    minute=now.minute();
    hour=now.hour(); 
 display.clearDisplay();
  }
  displaytime();        // display the current time
}
 void testscrolltext(void) {
  display.setTextSize(1);
  display.setTextColor(WHITE);
}
void displaytime(void){
  // start by clearing the display to a known state
display.clearDisplay();
display.setCursor(30,0);
 display.print("It is");
 display.println(" ");
display.display();
  // now we display the appropriate minute counter
  if ((minute>4) && (minute<10)) { 
    MFIVE; 
    MINUTES; 
      display.setCursor(1,10);
     display.print("Five Minutes ");
      display.println(" ");
      display.display();
   } 
  if ((minute>9) && (minute<10)) { 
    MTEN; 
    MINUTES; 
      display.setCursor(1,10);
     display.print("Ten Minutes ");
       display.println(" ");
     display.display();
    }
  if ((minute>14) && (minute<20)) {
    QUARTER; 
       display.setCursor(1,10);
     display.print("A Quarter ");
      display.println(" ");
      display.display();
     }
  if ((minute>19) && (minute<25)) { 
    TWENTY; 
    MINUTES; 
     display.setCursor(1,10);
     display.print("Twenty Minutes ");
      display.println(" ");
      display.display();
     }
  if ((minute>24) && (minute<30)) { 
    TWENTY; 
    MFIVE; 
    MINUTES;
      display.setCursor(1,10);
     display.print("Twenty Five Minutes ");
      display.println(" ");
      display.display();
      }  
  if ((minute>29) && (minute<35)) {
    HALF;
       display.setCursor(1,10);
     display.print("Half ");
       display.println(" ");
       display.display();
    }
  if ((minute>34) && (minute<40)) { 
    TWENTY; 
    MFIVE; 
     display.setCursor(1,10);
     display.print("Twenty Five Minutes ");
       display.println(" ");
       display.display();
   }  
  if ((minute>39) && (minute<45)) { 
    TWENTY; 
    MINUTES; 
    display.setCursor(1,10);
     display.print("Twenty Minutes ");
       display.println(" ");
      display.display();
   }
  if ((minute>44) && (minute<50)) {
    QUARTER; 
    display.setCursor(1,10);
     display.print("A Quarter ");
       display.println(" ");
      display.display();
  }
  if ((minute>49) && (minute<55)) { 
    MTEN; 
    MINUTES; 
      display.setCursor(1,10);
     display.print("Ten Minutes ");
       display.println(" ");
     display.display();
  } 
  if (minute>54) { 
    MFIVE; 
    MINUTES; 
     display.setCursor(1,10);
     display.print("Five Minutes ");
      display.println(" ");
     display.display();
  }
  if ((minute <5))
  {
    switch (hour) {
    case 1:
    case 13: 
      ONE; 
        display.print("One O'Clock");
        display.display();
      break;
    case 2:
    case 14: 
      TWO; 
         display.print("Two O'Clock");
         display.display();
      break;
    case 3: 
    case 15:
      THREE; 
         display.print("Three O'Clock");
         display.display();
      break;
    case 4: 
    case 16:
      FOUR; 
         display.print("Four O'Clock");
         display.display();
      break;
    case 5: 
    case 17:
      HFIVE; 
        display.print("Five O'Clock");
         display.display();
      break;
    case 6: 
    case 18:
      SIX; 
         display.print("Six O'Clock");
         display.display();
      break;
    case 7: 
    case 19:
      SEVEN; 
         display.print("Seven O'Clock");
         display.display();
      break;
    case 8: 
    case 20:
      EIGHT; 
         display.print("Eight O'Clock");
         display.display();
      break;
    case 9: 
    case 21:
      NINE; 
         display.print("Nine O'Clock");
         display.display();
      break;
    case 10:
    case 22: 
      HTEN; 
         display.print("Ten O'Clock");
         display.display();
      break;
    case 11:
    case 23: 
      ELEVEN; 
        display.print("Eleven O'Clock");
         display.display();
      break;
    case 0:
    case 12: 
      TWELVE; 
         display.print("Twelve O'Clock");
         display.display();
      break;
    }

  } else
    if ((minute < 35) && (minute >4))
    {
      PAST;
         display.print("Past  ");
         display.display();
      switch (hour) {
      case 1:
      case 13: 
        ONE; 
           display.print("One O'Clock");
           display.display();
        break;
      case 2: 
      case 14:
        TWO; 
           display.print("Two O'Clock");
           display.display();
        break;
      case 3: 
      case 15:
        THREE; 
           display.print("Three O'Clock");
           display.display();
        break;
      case 4: 
      case 16:
        FOUR; 
           display.print("Four O'Clock");
           display.display();
        break;
      case 5: 
      case 17:
        HFIVE; 
           display.print("Five O'Clock");
           display.display();
        break;
      case 6: 
      case 18:
        SIX; 
           display.print("Six O'Clock");
           display.display();
        break;
      case 7: 
      case 19:
        SEVEN; 
           display.print("Seven O'Clock");
           display.display();
        break;
      case 8: 
      case 20:
        EIGHT; 
           display.print("Eight O'Clock");
           display.display();
        break;
      case 9: 
      case 21:
        NINE; 
           display.print("Nine O'Clock");
           display.display();
        break;
      case 10:
      case 22: 
        HTEN; 
           display.print("Ten O'Clock");
           display.display();
        break;
      case 11:
      case 23: 
        ELEVEN; 
           display.print("Eleven O'Clock");
           display.display();
        break;
      case 0:
      case 12: 
        TWELVE; 
           display.print("Twelve O'Clock");
           display.display();
        break;
      }
    }
    else
    {
      // if we are greater than 34 minutes past the hour then display
      // the next hour, as we will be displaying a 'to' sign
      TO;
        display.print("To ");
         display.display();
      switch (hour) {
      case 1: 
      case 13:
        TWO; 
           display.print("Two O'Clock");
           display.display();
        break;
      case 14:
      case 2: 
        THREE; 
           display.print("Three O'Clock");
           display.display();
        break;
      case 15:
      case 3: 
        FOUR; 
           display.print("Four O'Clock");
           display.display();
        break;
      case 4: 
      case 16:
        HFIVE; 
           display.print("Five O'Clock");
           display.display();
        break;
      case 5: 
      case 17:
        SIX; 
           display.print("Six O'Clock");
           display.display();
        break;
      case 6: 
      case 18:
        SEVEN; 
           display.print("Seven O'Clock");
           display.display();
        break;
      case 7: 
      case 19:
        EIGHT; 
          display.print("Eight O'Clock");
           display.display();
        break;
      case 8: 
      case 20:
        NINE; 
           display.print("Nine O'Clock");
           display.display();
        break;
      case 9: 
      case 21:
        HTEN; 
           display.print("Ten O'Clock");
           display.display();
        break;
      case 10: 
      case 22:
        ELEVEN; 
         display.print("Eleven O'Clock");
         display.display();
        break;
      case 11: 
      case 23:
        TWELVE; 
           display.print("Twelve O'Clock");
           display.display();
        break;
      case 0:
      case 12: 
        ONE; 
           display.print("One O'Clock");
           display.display();
        break;
      }
    }

 }

void loop()
{
  DateTime now = RTC.now();
    second=now.second(); 
    minute=now.minute();
     hour=now.hour();
  if ( millis() - msTick >5000) {
    msTick=millis();
    digitalWrite(13,HIGH);
    delay(50);
    digitalWrite(13,LOW);  
    delay(50);
    digitalWrite(13,HIGH);
    delay(50);
    digitalWrite(13,LOW);  
  }
  if (second==59) // Update the display every 1 minute...
  
 {
     displaytime();
   }
  }		  

Schematics

oled word clock
oled_word_clock_e3JoI8VAfi.fzz

Comments

Similar projects you might like

Arduino to-the-minute word clock OLED Display

Project showcase by garysat

  • 1,308 views
  • 0 comments
  • 3 respects

Minimal Parts OLED Word Clock

Project showcase by garysat

  • 833 views
  • 0 comments
  • 2 respects

Complete Digital Clock Including Alarm and Motion Sensor

Project tutorial by LAGSILVA

  • 12,684 views
  • 11 comments
  • 50 respects

Italian Word Clock

Project tutorial by Tittiamo

  • 5,064 views
  • 2 comments
  • 15 respects

Arduino Analog/Digital Clock with Nokia 5110

Project showcase by garysat

  • 2,695 views
  • 5 comments
  • 6 respects

4-Stroke Digital Clock With Arduino

Project showcase by LAGSILVA

  • 11,105 views
  • 9 comments
  • 39 respects
Add projectSign up / Login