Project showcase
Arduino to-the-minute word clock OLED Display

Arduino to-the-minute word clock OLED Display © GPL3+

An Arduino based word clock that tells the day of the week, the month, day and year and the time to the minute in words.

  • 1,448 views
  • 0 comments
  • 3 respects

Components and supplies

About this project

This project, another clock, gives all the information you need with up to the minute time in words on a 128 X 32 OLED display. Small, compact, easy to wire, long code but fun. Used legos to build a little enclosure.

Code

tothe minute word clockArduino
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#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
#define Today
RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {
  while (!Serial); // for Leonardo/Micro/Zero

  Serial.begin(9600);
 
  
  if (! rtc.begin()) {
   
    while (1);
  }

  if (! rtc.isrunning()) {
  
    // following line sets the RTC to the date & time this sketch was compiled
     rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
  Wire.begin();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
  // init done
  //Clear the buffer.
  display.clearDisplay();
 text(); 
}
void text(void) {
  display.setTextSize(1);
  display.setTextColor(WHITE);
}
void Display () {
  display.clearDisplay();
    DateTime now = rtc.now();
    
 //set day of week   
     display.setCursor(0,0);
  display.print("Today is ");
    
display.print(daysOfTheWeek[now.dayOfTheWeek()]);
 
      
//set date 
    display.setCursor(0,12);
    int mo=now.month();
   
    if ((mo>0)&&(mo<2)){
      display.print("January ");
    }
    if ((mo>1)&&(mo<3)){
      display.print("February ");
    }
     if ((mo>2)&&(mo<4)){
      display.print("March ");
    }
    if ((mo>3)&&(mo<5)){
      display.print("April ");
    }
    if ((mo>4)&&(mo<6)){
      display.print("May ");
    }
    if ((mo>5)&&(mo<7)){
      display.print("June ");
    }
     if ((mo>6)&&(mo<8)){
      display.print("July ");
    }
    if ((mo>7)&&(mo<9)){
      display.print("August ");
    }
     if ((mo>8)&&(mo<10)){
      display.print("September ");
    }
    if ((mo>9)&&(mo<11)){
     display.print("October ");
    }
     if ((mo>10)&&(mo<12)){
      display.print("November ");
    }
    if ((mo>11)&&(mo<13)){
      display.print("December ");
    }
    
  
  display.print (now.day(), DEC);
  

  display.print(", ");
    
  display.print (now.year(), DEC);

 //set hour  
 display.setCursor(0,24);
  int hr=now.hour();
   if (hr>12){
     hr=hr-12;
   }
    if ((hr>0)&&(hr<2)){
      display.print("One ");
    }
  if ((hr>1)&&(hr<3)){
      display.print("Two ");
    }
    if ((hr>2)&&(hr<4)){
      display.print("Three ");
    }
     if ((hr>3)&&(hr<5)){
      display.print("Four ");
    }
    if ((hr>4)&&(hr<6)){
      display.print("Five ");
    }
     if ((hr>5)&&(hr<7)){
      display.print("Six ");
    }
     if ((hr>6)&&(hr<8)){
      display.print("Seven ");
    }
     if ((hr>7)&&(hr<9)){
    display.print("Eight ");
    }
     if ((hr>8)&&(hr<10)){
    display.print("Nine ");
    }
     if ((hr>9)&&(hr<11)){
      display.print("Ten ");
    }
     if ((hr>10)&&(hr<12)){
      display.print("Eleven ");
    
     
    }
     if ((hr>11)&&(hr<13)){
     display.print("Twelve ");
    }
 
   
   // set minute
    
   int m=now.minute();
   
    if ((m>0)&&(m<2)){
     display.print("O-One");
    }
        if ((m>1)&&(m<3)){
     display.print("O-Two");
    }
      
        if ((m>2)&&(m<4)){
      display.print("O-Three");
    }
      if ((m>3)&&(m<5)){
     display.print("O-Four");
    }
        if ((m>4)&&(m<6)){
      display.print("O-Five");
    }
      
        if ((m>5)&&(m<7)){
      display.print("O-Six");
    }
    
     if ((m>6)&&(m<8)){
      display.print("O-Seven");
    }
        if ((m>7)&&(m<9)){
      display.print("O-Eight");
    }
      
        if ((m>8)&&(m<10)){
      display.print("O-Nine");
    }
      
    //teens  
      if ((m>9)&&(m<11)){
      display.print("Ten");
    }
        if ((m>10)&&(m<12)){
      display.print("Eleven");
    }
      
        if ((m>11)&&(m<13)){
      display.print("Twelve");
    }
    
     if ((m>12)&&(m<14)){
      display.print("Thirteen");
    }
        if ((m>13)&&(m<15)){
      display.print("Fourteen");
    }
      
        if ((m>14)&&(m<16)){
      Serial.print("Fifteen");
    }
      if ((m>15)&&(m<17)){
      display.print("Sixteen");
    }
        if ((m>16)&&(m<18)){
      display.print("Seventeen");
    }
      
        if ((m>17)&&(m<19)){
      display.print("Eighteen");
    }
    
     if ((m>18)&&(m<20)){
      display.print("Ninteen");
    }
      
   //twenty   
        if ((m>19)&&(m<21)){
     display.print("Twenty");
    }
      
        if ((m>20)&&(m<22)){
      Serial.print("Twenty-One");
    }
      if ((m>21)&&(m<23)){
      display.print("Twenty-Two");
    }
        if ((m>22)&&(m<24)){
      display.print("Twenty-Three");
    }
      
        if ((m>23)&&(m<25)){
      Serial.print("Twenty-Four");
    }
    
        if ((m>24)&&(m<26)){
      display.print("Twenty-Five");
    }
      if ((m>25)&&(m<27)){
      display.print("Twenty-Six");
    }
        if ((m>26)&&(m<28)){
      display.print("Twenty-Seven");
    }
      
        if ((m>27)&&(m<29)){
      Serial.print("Twenty-Eight");
    }
    
        if ((m>28)&&(m<30)){
      display.print("Twenty-Nine");
    }
    
    // thirty
     if ((m>29)&&(m<31)){
      display.print("Thirty");
    }
      
        if ((m>30)&&(m<32)){
      display.print("Thirty-One");
    }
      if ((m>31)&&(m<33)){
      display.print("Thirty-Two");
    }
        if ((m>32)&&(m<34)){
      display.print("Thirty-Three");
       
    }
      
        if ((m>33)&&(m<35)){
      display.print("Thirty-Four");
        
    }
    
        if ((m>34)&&(m<36)){
    display.print("Thirty-Five");
   
    }
      if ((m>35)&&(m<37)){
    display.print("Thirty-Six");
   
    }
        if ((m>36)&&(m<38)){
      display.print("Thirty-Seven");
     
    }
      
        if ((m>37)&&(m<39)){
      display.print("Thirty-Eight");
    }
    
        if ((m>38)&&(m<40)){
      display.print("Thirty-Nine");
    }
    
    //forty
     if ((m>39)&&(m<41)){
      display.print("Forty");
    }
      
        if ((m>40)&&(m<42)){
      display.print("Forty-One");
    }
      if ((m>41)&&(m<43)){
      display.print("Forty-Two");
    }
        if ((m>42)&&(m<44)){
     display.print("Forty-Three");
    }
      
        if ((m>43)&&(m<45)){
     display.print("Forty-Four");
    }
    
        if ((m>44)&&(m<46)){
     display.print("Forty-Five");
    }
      if ((m>45)&&(m<47)){
      display.print("Forty-Six");
    }
        if ((m>46)&&(m<48)){
      display.print("Forty-Seven");
    }
      
        if ((m>47)&&(m<49)){
      display.print("Forty-Eight");
    }
    
        if ((m>48)&&(m<50)){
      display.print("Forty-Nine");
    }
    
    //fifty
      if ((m>49)&&(m<51)){
      display.print("Fifty");
    }
      
        if ((m>50)&&(m<52)){
      display.print("Fifty-One");
    }
      if ((m>51)&&(m<53)){
      display.print("Fifty-Two");
    }
        if ((m>52)&&(m<54)){
      display.print("Fifty-Three");
    }
      
        if ((m>53)&&(m<55)){
      display.print("Fifty-Four");
    }
    
        if ((m>54)&&(m<56)){
      Serial.print("Fifty-Five");
    }
      if ((m>55)&&(m<57)){
      display.print("Fifty-Six");
    }
        if ((m>56)&&(m<58)){
      display.print("Fifty-Seven");
    }
      
        if ((m>57)&&(m<59)){
      display.print("Fifty-Eight");
    }
    
        if ((m>58)){
      display.print("Fifty-Nine");
    }
    
        if (m<1){
      display.print("O'Clock");
    }
    
       
    display.print(" ");
 
      int tm=now.hour();
    if (tm<13){
    display.print("AM");
  }
  
 
  
    if (tm>12){
    display.print("PM");
    }
  
   display.display();
}
void loop()

  
 {
     Display();
     delay(0);
   }

Schematics

ttmwordclcok
ttmwordclock_yRJJdcBvrp.fzz

Comments

Similar projects you might like

Arduino OLED Word Clock

Project showcase by garysat

  • 4,314 views
  • 0 comments
  • 12 respects

Minimal Parts OLED Word Clock

Project showcase by garysat

  • 833 views
  • 0 comments
  • 2 respects

Adjusting Dual Clock using DS3231 on 1.8" ST7735 Display

Project showcase by FLORICA Tudor-Nicusor

  • 3,968 views
  • 2 comments
  • 11 respects

Digital & Binary Clock In 8 Digits x 7 Segments LED Display

Project showcase by LAGSILVA

  • 1,827 views
  • 2 comments
  • 9 respects

Italian Word Clock

Project tutorial by Tittiamo

  • 5,068 views
  • 2 comments
  • 15 respects

Arduino Analog/Digital Clock with Nokia 5110

Project showcase by garysat

  • 3,215 views
  • 5 comments
  • 7 respects
Add projectSign up / Login