Last active
May 24, 2020 14:38
-
-
Save gtataranni/6aa3e6e6984cf98283f799215fbe0cce to your computer and use it in GitHub Desktop.
Seven segments number transition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from Adafruit_LED_Backpack import SevenSegment | |
# bit offset and corresponding led | |
# 0 | |
# 5 1 | |
# 6 | |
# 4 2 | |
# 3 | |
display = SevenSegment.SevenSegment() | |
display.begin() | |
display.clear() | |
fromNseq = [ | |
[84, 8, 0], # 0 -> | |
[4, 0], # 1 -> | |
[88, 8, 0], # 2 -> | |
[76, 8, 0], # 3 -> | |
[4, 0], # 4 -> | |
[76, 8, 0], # 5 -> | |
[92, 8, 0], # 6 -> | |
[4, 0], # 7 -> | |
[92, 8, 0], # 8 -> | |
[12, 8, 0] # 9 -> | |
] | |
toNseq = [ | |
[1, 35, 0x3f], # -> 0 | |
[2, 0x06], # -> 1 | |
[1, 67, 0x5b], # -> 2 | |
[1, 67, 0x4f], # -> 3 | |
[98, 0x66], # -> 4 | |
[1, 97, 0x6d], # -> 5 | |
[1, 97, 0x7d], # -> 6 | |
[1, 3, 0x07], # -> 7 | |
[1, 99, 0x7f], # -> 8 | |
[1, 99, 0x6f] # -> 9 | |
] | |
seq = [ [84, 8, 0, 2, 0x06], # 0 -> 1 | |
[4, 0, 1, 67, 0x5b], # 1 -> 2 | |
[88, 8, 0, 1, 67, 0x4f], # 2 -> 3 | |
[76, 8, 0, 98, 0x66], # 3 -> 4 | |
[4, 0, 1, 97, 0x6d], # 4 -> 5 | |
[76, 8, 0, 1, 97, 0x7d], # 5 -> 6 | |
[92, 8, 0, 1, 3, 0x07], # 6 -> 7 | |
[4, 0, 1, 99, 0x7f], # 7 -> 8 | |
[92, 8, 0, 1, 99, 0x6f], # 8 -> 9 | |
[12, 8, 0, 1, 35, 0x3f] # 9 -> 0 | |
] | |
while True: | |
for fx in seq: | |
for i in fx: | |
display.clear() | |
display.set_digit_raw(3, i) | |
display.write_display() | |
time.sleep(0.1) | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Final result: