Home        Kenley Weather     Guestbook

Section    Top    Overview   Credits      Controls      Power   PIR     Build   Segment Build     2 Colour Printing    3D Printed Parts   Electronic Modules    Control Panel     9G Servos     Servo Setup    Schematic     Vero Board     Code

 

 

 

WIFI Synchronized 7 Segment Servo Motor Clock using an Arduino Nano & 3D Printed 7 Segment Displays

Features

Large 545mm (21.4") x 185mm (7.2") display

185mm (7.2") Digits

Battery backed up RTC

FTP Synchronization over WIFI

PIR Display Control

Seconds displayed using a 60 LED strip as backlighting

 

 

 

 

 

 

Project Overview

A large (640mm x 290mm) wall mounted 7 segment servo motor clock using an Arduino Nano microcontroller to drive 28 servo motors via 2 x 16 channel servo controllers.

 

A Wemos D1 mini ESP-8266 microcontroller provides FTP sync for the clock on 30 seconds and also drives a string of 60 LEDs (WS2812 60 LED strip).

 

The 60 LEDs display the seconds as a backlight to the rear of the clock either as a single LED or 59 LEDs on with a single contrasting LED indicating the seconds.

 

 

Below the seconds are displayed in a linear mode clockwise

A PIR input stops the clock running and turns off the LED backlight when no one is in the room.


The 7 segment displays are 3D printed with white fronts with black backs and mounts are 3D printed in black.

The WEMOS mini and LED strip are optional.

The clock is housed in a wooden case with a Perspex hinged cover

The circuit uses many prebuilt module and is easily built onto Vero Board

 

 

 

Credits

This clock is based on an original design by MICHAEL KLEMENTS

See it on Github

Michael Klement's version with translucent green PLA digits

 

 

 

 

 

 

 

 

 

 



Controls

There are two control panels on the clock one at the top of the case and one at the bottom.

The lower control panel controls the 7 segment clock (Nano) and the upper control panel controls the LED backlight and WEMOS D1 Mini.

In normal use the control panels are hidden beneath black 3D printed covers.

 

 

 

Lower Control Panel 7 Segment Clock


Set Time On

When on and power is reset clock boots into time setting mode


Set Time

When pressed the digit selected on the Set Time control is sent to the clock and set on that digit


30 Sec Sync

Clock seconds are set to 30 seconds on receipt of the 30 second pulse from the Wemos D1 Mini 


PIR

Turns the PIR on or off


Program/ Reset

When on power is connected to the Nano via the main PSU.

When off the power to the Arduino is fed via the USB. This is used when programming the Nano.

If off and USB power is removed and restored then this acts as a reset switch

 

 

 

 


Upper Control Panel Wemos D1 Mini


Brightness Down

Pressing and holding steps the LED brightness down until off


Brightness Up

Pressing and holding steps the LED brightness up



Reset
Pressing Reset resets the Wemos D1 Mini


Display Mode
Pressing Display Mode steps through the pre-programmed seconds display LED strip colours and effects
You can program any colour you like and can have a single LED indicate the seconds or all LEDs on with a non lit LED indicating the seconds.

Changing modes in the code
Any colour combination can be chosen. You can even display the mins and hours on the LEDs as well.
Set the Seconds LED colour in setmode() Line 175 onwards controls colours- set  to black to turn LED off
void setmode(){
//ModeValue = digitalRead(Mode);
if (digitalRead(Mode) == HIGH)
{
ModeValue = ModeValue +1;
colorSecond = CRGB::Blue;//Black;//Brett
Serial.println("Secs Colour Blue ");

if(ModeValue == 5)// Sets the number of modes eg 5 will be 4 modes add modes to the if statements below
{
ModeValue = 0;
}

}
// Set colour of Seconds LED. ## Note background LED colour set on line 168
if (ModeValue == 0)
{

colorSecond = CRGB::Blue;

Serial.print("Secs Colour Blue/Yellow Mode Value ");
Serial.println(ModeValue);
}


if (ModeValue == 1)
{

colorSecond = CRGB::Red;

Serial.print("Secs Colour Red/Yellow Mode Value ");
Serial.println(ModeValue);
}

if (ModeValue == 2)
{
colorSecond = CRGB::Magenta;
CRGB colorHourSecond = CRGB::Magenta;
CRGB colorMinuteSecond = CRGB::Magenta;

Serial.print("Secs Colour Magenta/Black Mode Value ");
Serial.println(ModeValue);
}

if (ModeValue == 3)
{
colorSecond = CRGB::White;

Serial.print("Secs Colour White/Black Mode Value ");
Serial.println(ModeValue);
}


if (ModeValue == 4)
{
colorSecond = CRGB::Red;

Serial.print("Secs Colour Red/White Mode Value ");
Serial.println(ModeValue);
}

}
for (int i=0; i<NUM_LEDS; i++)

//Sets the colour of all the off LEDs

// make number of modes the same as set in setmode()
if (ModeValue == 0)
{
LEDs[i] = CRGB::Magenta;//(242, 231, 48);//::Yellow;//Green;Black;//Brett


// Set min and hour LEDs to match background colours if required.
CRGB colorHour = CRGB::Black;
CRGB colorMinute = CRGB::Black;

}

else if (ModeValue == 1)
{
LEDs[i] = CRGB::Yellow;//(242, 231, 48);//::Yellow;//Green;Black;//Brett
// Set min and hour LEDs to match background colours if required.
// CRGB colorHour = CRGB::Yellow;
// CRGB colorMinute = CRGB::Yellow;
}


else if (ModeValue == 2)
{
LEDs[i] = CRGB::Black;//(242, 231, 48);//::Yellow;//Green;Black;//Brett
// Set min and hour LEDs to match background colours if required.
CRGB colorHour = CRGB::Black;
CRGB colorMinute = CRGB::Black;
CRGB colorHourSecond = CRGB::Magenta;
CRGB colorMinuteSecond = CRGB::Magenta;
}

else if (ModeValue == 3)
{
LEDs[i] = CRGB::Black;//(242, 231, 48);//::Yellow;//Green;Black;//Brett
// Set min and hour LEDs to match background colours if required.
CRGB colorHour = CRGB::Black;
CRGB colorMinute = CRGB::Black;
}

else if (ModeValue == 4)
{
LEDs[i] = CRGB::White;//(242, 231, 48);//::Yellow;//Green;Black;//Brett
// Set min and hour LEDs to match background colours if required.
CRGB colorHour = CRGB::White;
CRGB colorMinute = CRGB::White;
}













 

 

YouTube video showing how the time is set on the clock

 

 

Power

The clock uses 250mA on standby PIR off, 300mA with PIR activated and up to around 1000mA for under a second when the servos are updating the time.

Use a 2 amp 5v power supply.

Note on first install any faulty servos that take a long time to find their set position will tend to draw much more current then this as many servos will be running as the same time.

Use the test program to check each servo works before connecting to the circuit.

 

Test sketch for 9G servos. Steps 0-90-180 every 0.5 second.

 

 

 

 

PIR

The PIR turns off the display updates and backlight LEDs when no one is around.

When movement is detected the display immediately updates to the correct time.

This has a huge effect on the lifetime of the servo motors and depending on the LED backlight mode you choose there is a power saving as well.

 

The charts below show how many times the servos are triggered for each digit over different time periods.

Segment 5 of the minutes units gets triggered 1152 times every day whereas most of the hours 10s segments only get activated 2 times a day.

Anti clash is where segments 2 and 6 operate to allow segment 7 to move without clashing.

NUMBER OF SERVO OPERATIONS OVER TIME

MINUTES UNITS
  SEGMENT NUMBER
  1 2 3 4 5 6 7
DIGIT 0 0 0 0 0 1 0 1
DIGIT 1 1 0 0 1 1 1 0
DIGIT 2 1 0 1 1 1 0 1
DIGIT 3 0 0 1 0 1 0 0
DIGIT 4 1 0 0 1 0 1 0
DIGIT 5 1 1 0 1 0 0 0
DIGIT 6 0 0 0 0 1 0 0
DIGIT 7 0 1 0 1 1 1 1
DIGIT 8 0 0 0 1 1 1 1
DIGIT 9 0 0 0 0 1 0 0
Anti Clash   2       2  
10 min Frequency 4 4 2 6 8 6 4
1 hour Frequency 24 24 12 36 48 36 24
1 Day Frequncy 576 576 288 864 1152 864 576
   
MINUTES TENS
  SEGMENT NUMBER
  1 2 3 4 5 6 7
DIGIT 0 0 0 0 0 1 0 1
DIGIT 1 1 0 0 1 1 1 0
DIGIT 2 1 0 1 1 1 0 1
DIGIT 3 0 0 1 0 1 0 0
DIGIT 4 1 0 0 1 0 1 0
DIGIT 5 1 1 0 1 0 0 0
Anti Clash   2       2  
1 hour Frequency 4 3 2 4 4 4 2
1 Day Frequncy 96 72 48 96 96 96 48
             
HOURS UNITS
  SEGMENT NUMBER
  1 2 3 4 5 6 7
DIGIT 0 0 0 0 0 1 0 1
DIGIT 1 1 0 0 1 1 1 0
DIGIT 2 1 0 1 1 1 0 1
DIGIT 3 0 0 1 0 1 0 0
DIGIT 4 1 0 0 1 0 1 0
DIGIT 5 1 1 0 1 0 0 0
DIGIT 6 0 0 0 0 1 0 0
DIGIT 7 0 1 0 1 1 1 1
DIGIT 8 0 0 0 1 1 1 1
DIGIT 9 0 0 0 0 1 0 0
Anti Clash   2       2  
10 hour Frequency 4 4 2 6 8 6 4
1 Day 10 8 6 14 20 13 10
HOURS TENS
  SEGMENT NUMBER
  1 2 3 4 5 6 7
DIGIT 0 0 0 0 0 1 0 1
DIGIT 1 1 0 0 1 1 1 0
DIGIT 2 1 0 1 1 1 0 1
DIGIT 3 0 0 1 0 1 0 0
Anti Clash   2       2  
1 Day Frequency 2 2 2 2 4 3 2

 

 

PIR Demo

 

 

Pexels from Pixabay 

 

 

Construction

The full size layout was drawn up in TurboCad and printed out on paper.

 

 

 

 

The backboard was cut from an offcut of 15mm veneered chipboard painted matt black.

 

 

 

 

The layout was then laid over the backboard and the drilling locations were marked through the paper onto the backboard using a bradle

 

 

The large holes for the servo cables were drilled using a small Forstner drill bit just wider than the width of the 3 pin servo connector.

The Forstner bit cuts a nice clean hole in the front of the backing board.

Smaller holes for the servo mounts were drilled with a conventional drill bit.

 

 

Digits and servos superimposed over the back board to show servo cable hole locations relative to the servos.

Front Box

The front box was cut from some old 15mm engineered Oak flooring and was screwed and glued together.

The box is 640mm x 270mm x 65mm and the backboard fits inside at the bottom.

The outside is painted white and the inside matt black.

 

 

Rear Box

The rear box is made from timber offcuts and measures 570mm x 215mm x 35mm agai screwed and glued.

This houses the Vero board and modules and is fixed to the rear of the backboard with screws.

The rear box is smaller than the front box and painted black all round as it makes the overall depth of the clock look smaller.

It also allows space for the backlight seconds LEDs to be mounted.

 

 

 

 

Assembled Case with backboard in place

Completed case with Perspex hinged cover in place.

The rear box is not visible from most angles so the clock appears slimmer.

 

Segment Construction

 

Segment glued to servo arm side veiw

 

 

 

 

Segment glued to servo arm rear side veiw

 

 

Segment showing detail of the two colour printing.



To print 2 colour  in Cura you can pause the printer just as it starts printing the black part and then change filament colour.
I set a script in Cura to automatically pause the printer at a set layer.
To do this first slice your object.

 



 
 
In the Cura menu select "Extensions" then "Post Processing" and then "Modify G-Code"

 
 
In the popup select "Add a script" then "Pause at height"



 
 



 
 
To find the correct layer to pause at drag the layer slider on the right down until the amount of white you want to print is shown.
The layer number will be shown on the slider.



 
When the printer pauses I have left the extruder hot so the old filament can be pulled out.
Insert the new filament and push it through the hot end until the colour runs true.
Pull back a little bit of filament then start the printer off again.
 

 

 

Once printed and to hide the white edge it is blackened using a thick black permanent marker leaving only the front face white.

 

 

 

 

 

Servo Gluing Jig with servo and segment in position ready for hot melt glue.

 

 

 

 

 

Colon

The colon is printed in 2 parts. The top is printed in 2 colours as above and the bottom printed just in black.

Two of these are required.

 

 

3D Printed Parts Download

Download these 3D printer files from Thingverse

 

1 Servo Mount Type 1

2 Servo Mount Type 2

3 Servo Mount Type 3

4 Switch spacer upper control panel

5 Hinge washer Perspex cover

6 Switch spacer lower control panel

7 Countersunk screw adjustment washer for servo mount

8 Colon dot  (print 2 layer if required)

9 Colon dot mount

 

 

 

 

Display Segment (print 2 layer if required)

 

 

 

Left lower control panel  (print 2 layer if required)       Right lower control panel cover

 

 

 

 

 

Left upper control panel  (print 2 layer if required)       Right upper control panel cover

 

 

 

 

 

 

NXP PCA9685 16 channel PWM controller Mount

Download from Thingverse

 

 

 

 

 

Electronic Modules

Arduino NANO

The Arduino Nano is a small, complete, and breadboard-friendly board based on the ATmega328 (Arduino Nano 3.x).

It has more or less the same functionality of the Arduino Duemilanove, but in a different package.

It lacks only a DC power jack, and works with a Mini-B USB cable instead of a standard one.

 

 

 

 

 

PCA9685

This module is a breakout board for the NXP PCA9685 16 channel PWM controller. It features 16 fully programmable PWM outputs with a 12bit resolution giving a total of 4096 programmable steps with a duty cycle being adjustable from 0% to 100%.

Additionally, the output frequency of all 16 channels can be programmed from 24Hz to 1526Hz. Intended for controlling the brightness of multiple LEDs, the programmability of its PWM outputs means that it can also be configured for producing PWM signals compatible with driving standard servos.

 In fact, this module has been designed with this purpose in mind with 16 sets of headers that allow for any servo with a standard header to be directly plugged into the module.

A screw terminal block provides a means of powering the attached servos from an external 5V PSU and so the number of servos you can drive from your microcontroller and so is not limited by the microcontrollers own power supply.


The module also includes an I2C header with 10K pullup resistors and so only requires two data pins (SDA & SCL) to control the module.

Solderable pads on the module provide a means of changing the default I2C address (0x40) to one of 62 options, meaning more than one module can be connected to the same I2C bus.

A wide operating range of 2.3V to 5.5V allows the module to be powered from a range of power supplies and when powered from a 3.3V supply is safe to interface to a Raspberry Pi or 3.3V or any other non 5V tolerant microcontrollers.

 

Available from Hobby Components

 

 

 

 

 

WEMOS D1 MINI

The WeMos D1 min PRO is a miniature wireless 802.11 (Wifi) microcontroller development board.

It turns the very popular ESP8266 wireless microcontroller module into a fully fledged development board.

Programming the D1 mini pro is as simple as programming any other Arduino based microcontroller as the module includes a built in microUSB interface allowing the module to be programmed directly from the Arduino IDE (requires the ESP8266 support to be added via board manager) with no additional hardware.

The D1 mini Pro is also designed to allow Wemos compatible shields to be plugged into the board in a similar way to the Arduino development board platform which greatly expands its capabilities.

There is already a large range of compatible shields available and can also be purchased via our website. Included with the module is a set of headers (requires soldering) that allow the shield to be easily added or removed from the D1 mini PRO.

Other features of the D1 Mini Pro include 11 digital input/output pins, 1 analogue input pin (3.2V Max), 16MB (128M bit) Flash, an external antenna connector, built in ceramic antenna and houses the new CP2104 US to UART IC.

Available from Hobby Components

 

 

 

 

 

 

 

Logic Level Converter

The bi-directional logic level converter is a small device that safely steps down 5V signals to 3.3V AND steps up 3.3V to 5V at the same time.

This level converter also works with 2.8V and 1.8V devices. Each level converter has the capability of converting 4 pins on the high side to 4 pins on the low side with two inputs and two outputs provided for each side.

The level converter is very easy to use. The board needs to be powered from the two voltages sources (high voltage and low voltage) that your system is using.

High voltage (5V for example) to the 'HV' pin, low voltage (3.3V for example) to 'LV', and ground from the system to the 'GND' pin.

 

 

 

 

 WS2812 60 LED Strip

Each LED has an integrated driver that allows you to control the color and brightness of each LED independently.

The combined LED/driver IC on these strips is the extremely compact WS2812B (essentially an improved WS2811 LED driver integrated directly into a 5050 RGB LED), which enables higher LED densities.

WS2812B uses a specialized one-wire control interface and requires strict timing.

 

 

 

 

 

PIR

The  PIR sensor module has three output pins VCC, Output and Ground. It has a built-in voltage regulator so it can be powered by any DC voltage from 4.5 to 12 volts, typically 5V is used.


There are two potentiometers on the board to adjust a couple of parameters:

Sensitivity– This sets the maximum distance that motion can be detected. It ranges from 3 meters to approximately 7 meters.


Time– This sets how long that the output will remain HIGH after detection. At minimum it is 3 seconds, at maximum it is 300 seconds or 5 minutes.

 

 

 

 

 

Control Panels

Where micro switches are used I have 3D printed spacers to keep the buttons just above the surface

 

 

 

 

 

 

 

 

3D printed top and bottom control boxes. The white fronts on black boxes were printed on a single colour 3D printer by pausing layers and changing the printer filament.

The lettering is printed on Inkjet transfer paper.

 

 

 

Completed control boxes

 

Controls

 

 

 

 

 

Micro Servo 9g SG90

Servo motors (or servos) are self-contained electric devices that rotate or push parts of a machine with great precision.

The simplicity of a servo is among the features that make them so reliable.


The heart of a servo is a small direct current (DC) motor, similar to what you might find in an inexpensive toy. These motors run on electricity from a battery and spin at high RPM (rotations per minute) but put out very low torque .

An arrangement of gears takes the high speed of the motor and slows it down while at the same time increasing the torque.

The gear design inside the servo case converts the output to a much slower rotation speed but with more torque (big force, little distance).

The amount of actual work is the same, just more useful. Gears in an inexpensive servo motor are generally made of plastic to keep it lighter and less costly.

 

 

 

 

 

 

 

Inside there is a pretty simple set-up: a small DC motor, potentiometer (in the green plastic holder), and a control circuit.

The motor is attached by gears to the control wheel. As the motor rotates, the potentiometer's resistance changes, so the control circuit can precisely regulate how much movement there is and in which direction.

When the shaft of the motor is at the desired position, power supplied to the motor is stopped. If not, the motor is turned in the appropriate direction.

The desired position is sent via electrical pulses through the signal wire.

 

 

 

The motor housing with gears. The gears also turn the potentiometer to sense the angle of rotation.

 

 

 

 

Gear housing

 

 

 

Dimensions

 

 

 

 

Servo Setup

Each servo has it's own calibration setting to allow differences in the splines.

In the code there are settings for each servo seperated by Hours mins and on and off.

 

Load the file "7SegmentClockSegmentSetup" into the Arduino IDE.

This will step the chosen Digit segments on & off repeatedly.

Starting at line 70 you will see the following.

//###################CHOOSE SEGMENT TO SETUP###############################
int setupSegments = 1; // selects which digit to setup segments on
//0 None 1-Munute Units 2- Minute 10s 3- Hours Units or 4 Hours 10s

//########################################################################

change the line " int setupSegments = 1;" to the segment you want to setup.

Load the setup program onto the NANO and each segment on the selected segment will operate and release.

Adjust the segments 1 by in the code and upload it to the NANO to test the new position.

 

 

 

// HOURS
//Hours | Unit Digit | Tens Digit |
// Segment Number 1 2 3 4 5 6 7 1 2 3 4 5 6 7
int segmentHOn[14] = {435,415,240,250,365,270,390,440,400,245,255,400,260,415}; //On positions for each Hour servo
int segmentHOff[14] = {230,215,420,440,165,470,185,230,200,435,460,205,450,200}; //Off positions for each Hour servo







// MINUTES
//Minutes | Unit Digit | Tens Digit |
// Segment Number 1 2 3 4 5 6 7 1 2 3 4 5 6 7
int segmentMOn[14] = {400,400,260,260,370,255,395,410,400,263,280,395,263,380}; //On positions for each Minute servo
int segmentMOff[14] = {190,190,470,490,150,470,180,180,180,480,500,180,480,150}; //Off positions for each Minute servo

 

 

 

Servo segments 3&4 

 

 

 

Servo segments 3&4

260 up to 510 right

 

 

 

 

 

 

 

 

 

 

 

Servo segments 5 & 7 

 

Servo segments 5 & 7

375 up to 180 left

 

 

 

 

 

 

 

 

 

 

Servo segments 1,& 2 

 

 

Servo segments 1,& 2

200 right & 400 top

        

 

 

 

 

 

Servo segments 4& 6 

 

Servo segments 4& 6

255 up  & 510 left

 

 

 

Schematic

 

Click on the Schematic for the full size version

 

 

 

 

 

 

 

 

Vero Board Layout

Front all modules attached.

 

Front modules removed.

 

Rear flipped down from top.

 

Rear Layout - note foam dust seal strip around the back of the clock

 

Locations of boards and WS2812 LED strip that indicates the seconds as a backlight.

 

Location of Vero board and PCA9685 on rear of case

 

 

Vero board/Modules showing relative location to the digits on the front of the clock

Code

There are two lots of code - one for the Arduino Nano which controls the servos and one for the WeMos D1 min Pro that controls the LED seconds display backlighting and wireless time sync.

Also included are setup codes for setting up positions of the servo segments.

 

Arduino Nano Code

 

 

WeMos D1 min Pro

Go to lines 36 & 37 and enter your  network SSID name and   network password between the speech marks

const char ssid[] = "SSID Name";// Your network SSID name here
const char pass[] = "Password"; // Your network password here

 

Setup Codes Arduino NANO

Digit Setup

Before loading find

//###################CHOOSE SEGMENT TO SETUP###############################
int setupSegments = 1; // selects which digit to setup segments on
//0 None 1-Munute Units 2- Minute 10s 3- Hours Units or 4 Hours 10s

//########################################################################

Change "int setupSegments = 1;" to the digit you want to setup.

Each servo on your selected digit will operate and release in turn

 

 

Servo Test

 

Put servo on 8th set of pins Hours Tens Segment 1

Steps 0-90-180 every 0.5 second.

 

Reject any servos that are slow, noisy or "hunt" to find any of the 3 positions.

If faulty servos are used in the clock it will cause high current consumption as the faulty servos will still be "hunting" while other servos are moving.