the_software_build_and_test
This is an old revision of the document!
The Software Build and Test
I want this page to contain the Software for the Clock, and for some test patterns, for now here is the code for the clock (remember, this code is for Common Anode displays)
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) # GPIO pins used to display 7 segments gpioSegments = (5,6,13,19,26,21,20,16) for segment in gpioSegments: GPIO.setup(segment, GPIO.OUT) GPIO.output(segment, 1) # GPIO pins used to select digit 0-3 gpioDigits = (18,23,24,25) for digit in gpioDigits: GPIO.setup(digit, GPIO.OUT) GPIO.output(digit, 0) dotted=False numbers = {'0':(0,0,1,0,1,0,0,0), '1':(1,1,1,0,1,0,1,1), '2':(0,0,1,1,0,0,1,0), '3':(1,0,1,0,0,0,1,0), '4':(1,1,1,0,0,0,0,1), '5':(1,0,1,0,0,1,0,0), '6':(0,0,1,0,0,1,0,0), '7':(1,1,1,0,1,0,1,0), '8':(0,0,1,0,0,0,0,0), '9':(1,0,1,0,0,0,0,0), ' ':(0,0,0,0,0,0,0,0)} try: while True: n = time.ctime()[11:13]+time.ctime()[14:16] s = str(n).rjust(4) for digit in range(4): for loop in range(0,8): GPIO.output(gpioSegments[loop], numbers[s[digit]][loop]) #if (int(time.ctime()[18:19])%2 == 0) and (digit == 2): # GPIO.output(23, 0) #else: # GPIO.output(23, 1) GPIO.output(gpioDigits[digit], 1) time.sleep(0.005) GPIO.output(gpioDigits[digit], 0) finally: GPIO.cleanup()
the_software_build_and_test.1485104189.txt.gz · Last modified: 2023/03/09 22:35 (external edit)