Project showcase
Arduino Analog/Digital Clock with Nokia 5110

Arduino Analog/Digital Clock with Nokia 5110 © GPL3+

An analog/digital clock using Arduino Nano, DS1307 & Nokia 5110.

  • 4,108 views
  • 5 comments
  • 9 respects

Components and supplies

About this project

As you have probably noticed from my project post I am obsessed with clocks. My objective in this project was to make a simple analog/digital clock using a Nokia 5110 display. Using an Arduino Nano, DS1307 and a Nokia 5110 from Banggood, it is possible to construct this clock inexpensively. You can use the Nokia 5110 with or without back light - just do or do not use pin 7 to ground. It was a fun project for me. The code is simple and so is the wiring.

Code

Analog_digital clockArduino
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 rtc;


// Software SPI (slower updates, more flexible pin options):
// pin 8 - Serial clock out (SCLK)
// pin 9 - Serial data out (DIN)
// pin 10- Data/Command select (D/C)
// pin 12- LCD chip select (CS)
// pin 11- LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(8, 9, 10, 12, 11);


void setup() {
  // put your setup code here, to run once:
  display.begin();
  display.setContrast(50);
  display.clearDisplay();
  display.display(); // show splashscreen

  Serial.begin(9600);
 if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
     rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  
  }
}

void loop() {
  DateTime now = rtc.now();
  int h=now.hour();
  int m=now.minute();
  int s=now.second();

  for(int i=0;i<10;i++)
    {
    drawClock(h,m,s);
    delay(1000);
    s++;
    if(s>=60) m++;
    s=s%60;
    if(m>=60) h++;
    m=m%60;
    h=h%24;
    }
}

void drawClock(int h, int m, int s)
{
const int r=15;
const double rot=-M_PI/2;
double x,y,x0,y0,anglerad;
  
  display.clearDisplay();
 //display.drawPixel(0,0,BLACK);
  display.drawPixel(24,24,BLACK);
  display.drawCircle(24,24,r,BLACK);
  for(int i=0;i<12;i++)
    {
    int angled=360/12*i;
    anglerad=2*M_PI/12*i+rot;
    x=r*cos(anglerad);
    y=r*sin(anglerad);
    x0=(r-3)*cos(anglerad);
    y0=(r-3)*sin(anglerad);
   Serial.print(h);
   Serial.print(":");
   Serial.print(m);
   Serial.print(":");
   Serial.print(s);
  
    Serial.println("");

    display.drawLine(24+x0,24+y0,24+x,24+y,BLACK);
    }

  // hour
   display.setCursor(19,1);
   display.print("12");
   display.setCursor(2,20);
   display.print("9");
   display.setCursor(43,20);
   display.print("3");
   display.setCursor(21,41);
   display.print("6");


  
  
  
   display.setCursor(54,4);
   display.print("TIME");
   display.setCursor(54,14);
 
   display.print(h);
   display.print(":");
   display.print(m);

  anglerad=2*M_PI/12*(h%12)+2*M_PI/12/60*m+rot;
  x=(r-7)*cos(anglerad);
  y=(r-7)*sin(anglerad);
  x0=0;
  y0=0;
  display.drawLine(24+x0,24+y0,24+x,24+y,BLACK);
  
  // minute
   anglerad=2*M_PI/60*m+rot;
  x=(r-5)*cos(anglerad);
  y=(r-5)*sin(anglerad);
  x0=0;
  y0=0;
  display.drawLine(24+x0,24+y0,24+x,24+y,BLACK);

  // second
  display.setCursor(63,22);
 
  display.print(s);
  
   anglerad=2*M_PI/60*s+rot;
  x=(r-2)*cos(anglerad);
  y=(r-2)*sin(anglerad);
  x0=0;
  y0=0;
  display.drawLine(24+x0,24+y0,24+x,24+y,BLACK);

 
  display.display();  
}

Schematics

analog/digital clock using nokia 5110
nokia5110analogclock_34o5aSg0sA.fzz

Comments

Similar projects you might like

Arduino OLED Word Clock

Project showcase by garysat

  • 5,572 views
  • 1 comment
  • 11 respects

Minimal Parts OLED Word Clock

Project showcase by garysat

  • 1,707 views
  • 0 comments
  • 5 respects

Complete Digital Clock Including Alarm and Motion Sensor

Project tutorial by LAGSILVA

  • 19,150 views
  • 21 comments
  • 65 respects

Arduino Cheap Minimal Parts Digital Clock

Project showcase by garysat

  • 14,890 views
  • 38 comments
  • 33 respects

Arduino to-the-minute word clock OLED Display

Project showcase by garysat

  • 2,278 views
  • 1 comment
  • 6 respects

Arduino nano stepper motor clock

Project showcase by garysat

  • 1,225 views
  • 1 comment
  • 2 respects
Add projectSign up / Login