Microview - Digital Clock

Introduction

This project is a very basic digital clock using the Microview as the display and microcontroller.

You Will Need

  • Microview
  • DS1307 RTC Breakout Board

Making The Circuit

This is a very simple circuit. A 9V battery is shown as the power source here. Powering over USB using either the programmer board or an FTDI cable/board is also possible.

Microview Digital Clock Circuit

Programming The Arduino

You need two libaries for this program, the Microview library and the RTC library.

There isn't too much going on here, just reading the time from the RTC and displaying it on the Microview.

#include <Wire.h>
#include "RTClib.h"
#include <MicroView.h>

RTC_DS1307 RTC;

char daynames[][6] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
char months[][12] = {"NO", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};


void setup() {
  Wire.begin();
  RTC.begin();
  uView.begin();
  uView.clear(ALL);
  uView.clear(PAGE);
}

void loop() {
  DateTime now = RTC.now();
  int mins = now.minute();
  int secs = now.second();
  int hr = now.hour();
  int monthday = now.day();
  int monthnum = now.month();
  int yr = now.year();
  int wkday = now.dayOfWeek();
  uView.setFontType(1);
  uView.setCursor(10, 0);
  uView.print(hr);
  uView.print(":");
  if (mins < 10)
  {
    uView.print(0);
  }
  uView.print(mins);
  uView.setCursor(2, 24);
  uView.setFontType(0);
  uView.print(daynames[wkday]);
  uView.print(" ");
  if (monthday < 10)
  {
    uView.print(0);
  }
  uView.print(monthday);
  uView.print(" ");
  uView.print(months[monthnum]);
  uView.display();
  delay(30000);
}

Challenges

  1. Adding a sensor or some sensors to the setup is a natural way to extend this project. On the easier end, a temperature sensor would be quite manageable. Remember that I2C pins can have more than one device attached as long as they have different addresses. A humidity sensor could therefore be used.
  2. Add a buzzer and a couple of buttons. You have the tools now to make your circuit into an alarm clock or stopwatch.
  3. If you are confident with the trigonometry for right angled triangles, you could look at the drawing functions in the Microview library and make a usable analogue face for your digital clock.