A Better Clock

Almost everybody knows of Doctor Urbano’s LED clock in the Makerspace and how blasphemous it is. So I’ve made a better one. Boasting 60, not 72, but 60 top-of-the-line AliExpress LEDs (definitely not made in a sweatshop), this clock doesn’t skip around every few seconds.

Procedure

I cut out two layers of wood on the laser cutter, and then glued them together, I used a Pico W because I need wifi to find the current time so the clock is accurate. Then I soldered wires to the LED’s and hooked them up to the Pico, and stuck the LED’s unto the wood frame. After I got all of the hardware done, I began doing the software, with Doctor Urbano’s help of course. The point of this project was to incorporate arc lengths and arc angles into it. The way I did that was by using equations to find the arc lengths of each hand, Then I had it print each one of them out, in real time.

Results

A working Clock, prints real-time arc lengths

The coding was relatively tricky because Doc and I tried to use 2 different versions and after a lot of finicking, we used version 8 of the pico, also because I don’t know much of coding. I am not sure If I will take this home or leave it in the Makerspace.

Discussion

This is very much an improvement from the original because this one doesn’t skip an LED every few seconds since it has 60 LEDS instead of 72. There isn’t really anything In particular that went wrong or bad in making it, I did have to resolder the wire to the LEDS a couple times but that’s because it was my first time soldering and the wires immediately bent at a 90-degree angle so I had to solder it very good. If I did this again, I would probably be able to do it much faster and probably slightly better.

$$ Arclength = \frac{HandDegrees}{360}\cdot 2\pi r $$

Code Used:

import socketpool
import wifi

from adafruit_httpserver.mime_type import MIMEType
from adafruit_httpserver.request import HTTPRequest
from adafruit_httpserver.response import HTTPResponse
from adafruit_httpserver.server import HTTPServer
import adafruit_ntp

import board
import time
from ledPixelsPico import *
from uNetComm import *
from uSchedule import *
from ledClock import *
from math import pi


# brightness Knob
brightness = 1.0

#ssid, password = secrets.WIFI_SSID, secrets.WIFI_PASSWORD  # pylint: disable=no-member
ssid, password = "TFS Students", "Fultoneagles"  # pylint: disable=no-member

pool = uNetConnect(ssid, password)
server = HTTPServer(pool)
# get time
#ntp = adafruit_ntp.NTP(pool, tz_offset=0)
clock = ledClock(board.GP15, 60, pool, True)
clock.initTime()


print(f"Listening on http://{wifi.radio.ipv4_address}:80")
# Start the server.
server.start(str(wifi.radio.ipv4_address))
t_zero = time.monotonic()

while True:
    
    dt = time.monotonic() - t_zero
    if dt >= 1.0:
        t_zero = time.monotonic()
        dtime = time.monotonic() - clock.zeroTime
        clock.now = clock.startTime.addSecs(dtime)
        #print(dtime, clock.now)
        print(f"Time: {clock.now.hr}:{clock.now.min}:{clock.now.sec}")
        #clock.lightToTime(clock.now)
        r = 39.3
        h = clock.now.hr
        m = clock.now.min
        s = clock.now.sec
        n = int(60/12*h)
        print(h,n)
        for i in range (60):
            clock.pixels[i]=(0,0,0)
        for i in range(h*5):
            clock.pixels[i]=(20,0,20)
            
        clock.pixels[m-1] = (70,30,0)
        clock.pixels[s-1] = (0,100,0)
        clock.show()
        hdegrees = h*30
        mdegrees = m*6
        sdegrees = s*6

        harclength = hdegrees/360*2*pi*r
        marclength = mdegrees/360*2*pi*r
        sarclength = sdegrees/360*2*pi*r

        print("arclength hours=", harclength)
        print("arclength minutes=",marclength)
        print("arclength seconds=",sarclength)

Leave a Reply