Introduction: Arduino Nano and Visuino: 7 Segment Display Clock With MAX7219 and DS1307 Real Time Clock(RTC)

DS1307 Real Time Clock are widely available low cost I2C RTC modules. They come with a clock and a small battery, and when connected to Arduino, can keep track of real time even when the Arduino board is not powered. I already made Instructable on how to use them with Arduino Nano . Some of you have asked, how you can display the time with LED Display.

In this Instructable, I will show you how to connect DS1307 I2C RTC Module, and the MAX7219 controlled 7 Segment LED Display to Arduino, read and display the time, and program all this with Visuino. I will use the Tiny RTC Module that I have, but it should be very much the same with any other DS1307 Module.

Step 1: Components

  1. One Arduino compatible board (I use Arduino Nano, because I have one, but any other will be just fine)
  2. One DS1307 Real Time Clock Module (I used Tiny RTC Module but any other DS1307 Module will be just fine)
  3. One 8 digits 7 Segment Display module with MAX7219 controller (Picture 2 shows the backside of the module with the MAX7219 controller)
  4. One small Breadboard (Any breadboard can be used, or any other way to connect 3 wires together)
  5. 3 Female-Male jumper wires
  6. 7 Female-Female jumper wires

Step 2: Connect the Real Time Clock to Arduino

  1. Connect the Female end of a Female-Male5V VCC Power(Red wire) to the DS1307 RTC Module (Picture 1)
  2. Connect Female-Female wires - Ground(Black wire), SCL(Orange wire), and SDA(Blue wire), to the DS1307 RTC Module (Picture 1)
  3. Connect the other end of the SDA wire(Blue wire) to SDA/Analog pin 4 of the Arduino Nano board (Picture 2)
  4. Connect the other end of the SCL wire(Orange wire) to SCL/Analog pin 5 of the Arduino Nano board (Picture 2)
  5. Connect the other end of the Ground wire(Black wire) to Ground pin of the Arduino Nano board (Picture 3)
  6. Picture 4 shows where are the Ground, SDA/Analog pin 4, and SCL/Analog pin 5, pins of the Arduino Nano

Step 3: Connect the LED Module to the Arduino

  1. Connect the Female end of a Female-Male 5V VCC Power(Red wire) to theLED Module (Picture 1)
  2. Connect Female-Female wires - Ground(Black wire), DIN(Green wire), CS(Gray wire), and CLK(Yellow wire) to theLED Module (Picture 1)
  3. Connect the other end of the Ground wire(Black wire) to Ground pin of the Arduino Nanoboard (Picture 2)
  4. Connect the other end of the CLK wire(Yellow wire) to the Digital 13 pin of the Arduino Nanoboard (Picture 3)
  5. Connect the other end of the DIN wire(Green wire) to the Digital 11 pin of the Arduino Nanoboard (Picture 4)
  6. Connect the other end of the CS wire(Gray wire) to the Digital 10 pin of the Arduino Nanoboard (Picture 4)
  7. Picture 5 shows In Red where are the Ground, Digital 10, 11, and 13, pins of the Arduino Nano. In Blue are shown the connections done in the previous step

Step 4: Connect the Power Wires to the Arduino Board

  1. Connect another Female-Male Power wire(Red wire) to the 5V Power pin of the Arduino board(Picture 1), and leave the Male end unconnected
  2. Connect the Male ends of the 3 Power wires(Red wires) - from the Display, the Clock Module, and the Arduino together as example with the help of a Breadboard (Picture 2) - In my case I used a small Breadboard
  3. Picture 3 shows In Red where is the 5V Power, pin of the Arduino Nano. In Blue are shown the connections done in the previous steps

Step 5: Start Visuino, and Select the Arduino Board Type

To start programming the Arduino, you will need to have the Arduino IDE installed from here: http://www.arduino.cc/.

Please be aware that there are some critical bugs in Arduino IDE 1.6.6.

Make sure that you install 1.6.7 or higher, otherwise this Instructable will not work!

The Visuino: https://www.visuino.com also needs to be installed.

  1. Start Visuino as shown in the first picture
  2. Click on the "Tools" button on the Arduino component (Picture 1) in Visuino
  3. When the dialog appears, select "Arduino Nano" as shown in Picture 2

Step 6: In Visuino: Add and Connect Maxim MAX7219 LED Component

  1. Type "led" in the Filter box of the Component Toolbox then select the "Maxim Led Controller SPI MAX7219/MAX7221" component (Picture 1), and drop it in the design area
  2. Connect the "Out" pin of the LedController1 component to the to the "In" pin of the SPI channel of the Arduino component (Picture 2)
  3. Connect the "ChipSelect" pin of the LedController1 component to the "Digital" input of the "Digital[ 10 ]" channel of the Arduino component (Picture 3)

Step 7: In Visuino: Add Integer Display 7 Segments Element to the Maxim LED Controller Component

The LedController1 component can control LEDs in many different ways. How the LEDs are organized and controlled depends on what Elements will be added to the component. Here we will add 3 Integer elements each with 2 digits, and 2 Unsigned Bit Pixel elements. The time will be displayed in the integer elements, and the bit pixels elements will be used for the separators between hours, minutes, and seconds:

  1. Click on the "Tools" button of the LedController1 component (Picture 1) to open the elements editor
  2. In the "Elements" editor, select the "Integer Display 7 Segments" on the right, and click on the "+" button on the left to add one element to the component (Picture 2)
  3. In the Object Inspector, set the value of the "CountDigits" property of the newly added "Integer Display 7 Segments1" element to 2 (Picture 3)
  4. In the Object Inspector, set the value of the "LeadingZeroes" property of the newly added "Integer Display 7 Segments1" element to "True" (Picture 4)

Step 8: In Visuino: Add the Rest of the Elements to the Maxim LED Controller Component

  1. In the "Elements" editor, select the "Unsigned Bit Pixels" on the right, and click on the "+" button on the left to add one element to the component (Picture 1)
  2. In the Object Inspector, set the value of the "CountPixels" property of the newly added "Unsigned Bit Pixels1" element to "8" (Picture 3)
  3. In the Object Inspector, set the value of the "InitialValue" property of the newly added "Unsigned Bit Pixels1" element to "1" (Picture 4). This will make the "-" (g) segment only active on the 7 segment digit
  4. Repeat the same steps from this and the previous Step 7 of the Instructable to add 2 more "Integer Display 7 Segments" elements, and one more "Unsigned Bit Pixels" element, and set their properties the same way (Picture 4)
  5. Close the "Elements" editor

Step 9: In Visuino: Add and Connect Decode Date/Time Component

We need to decode the Date/Time into separated Hour, Minute, and Second values. For this we will use "Decode Date/Time" component:

  1. Type "decode" in the Filter box of the Component Toolbox then select the "Decode Date/Time" component (Picture 1), and drop it in the design area
  2. Connect the "Out" pin of the RealTimeClock1 to the "In" pin of the DecodeDateTime1 (Picture 2)
  3. Connect the "Second" pin of the "Out" pin list of the DigitalToUnsigned1 to the "In" pin of the "PixelGroups.Integer Display 7 Segments1" element of the LedController1 component (Picture 3)
  4. Connect the "Minute" pin of the "Out" pin list of the DigitalToUnsigned1 to the "In" pin of the "PixelGroups.Integer Display 7 Segments2" element of the LedController1 component (Picture 4)
  5. Connect the "Hour" pin of the "Out" pin list of the DigitalToUnsigned1 to the "In" pin of the "PixelGroups.Integer Display 7 Segments3" element of the LedController1 component (Picture 5)

Step 10: In Visuino: Add and Connect T Flip Flop Component

To animate the "-" separator segments between the Hours, Minutes, and the Seconds, we will switch between "8", and "1" unsigned values every second. To do this we can use a Flip-Flop. The most convenient for this purpose is the Toggle(T)-FlipFlop:

  1. Type "flip" in the Filter box of the Component Toolbox then select the "Toggle(T) Flip-Flop" component (Picture 1), and drop it in the design area
  2. Connect the "Out" pin of the RealTimeClock1 to the "In" pin of the TFlipFlop1 component (Picture 2)

Step 11: In Visuino: Add, Configure, and Connect Digital to Unsigned Component

The Flip flop generates a Digital(Boolean) value. We need to convert it to unsigned values of "8", and "1". To do this we will use "Digital To Unsigned" converter:

  1. Type "digital" in the Filter box of the Component Toolbox then select the "Digital To Unsigned" component (Picture 1), and drop it in the design area
  2. In the Object Inspector, set the value of the "FalseValue" property of the DigitalToUnsigned1 element to "8" (Picture 2)
  3. Connect the "Out" pin of the TFlipFlop1 to the "In" pin of the DigitalToUnsigned1 component (Picture 3)
  4. Connect the "Out" pin of the DigitalToUnsigned1 to the "In" pin of the "PixelGroups.Unsigned Bit Pixels1" element of the LedController1 component (Picture 4)
  5. Connect the "Out" pin of the DigitalToUnsigned1 to the "In" pin of the "PixelGroups.Unsigned Bit Pixels2" element of the LedController1 component (Picture 5)

Step 12: Generate, Compile, and Upload the Arduino Code

  1. In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE
  2. In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

Step 13: And Play...

Congratulations! You have made an LED clock with 7 Segments MAX7219 LED Display driver, and DS1307 Real Time Clock(RTC).

Picture 1, and the Video show the connected and powered up project.

If you power Arduino, you will see the time displayed on the 7 Segment Display.

On Picture 2 you can see the complete Visuino diagram.

Also attached is the Visuino project, that I created for this Instructable. You can download and open it in Visuino: https://www.visuino.com

Raspberry Pi Contest 2016

Participated in the
Raspberry Pi Contest 2016