Close

Getting messy

A project log for Abacus Clock

A clock that uses Abacus logic to display the current time.

Steven RochSteven Roch 05/14/2016 at 14:211 Comment

--UPDATE TWO--

Now I've come up with a way to reduce the amount of code drastically.

I will use 10 functions to turn the LEDs on and off depending on the current time. This is 'eight' for example:

def displayEight(led_1, led_2, led_3, led_4, led_5):
    GPIO.output(led_1, True)
    GPIO.output(led_2, True)
    GPIO.output(led_3, True)
    GPIO.output(led_4, True)
    GPIO.output(led_5, False)

In addition I installed another row of LEDs today but now I don't have any more LEDs and need to order some which is why I won't be posting any updates for a few days.

Here's how my breadboard is looking right now (don't mind the knife, I needed to open a pack of resistors):

Discussions

Yann Guidon / YGDES wrote 05/15/2016 at 19:35 point

Just some random code, not tested, i'm not fluent in Python...

def display(number)
    var i=conversion_array[number]
    GPIO.output(led_1, i&1)
    i = i >> 1
    GPIO.output(led_2, i&1)
    i = i >> 1
    GPIO.output(led_3, i&1)
    i = i >> 1
    GPIO.output(led_4, i&1)
    i = i >> 1
    GPIO.output(led_5, i&1)

Now you just have to create conversion_array

  Are you sure? yes | no