Micropython ESP32 Lesson 2.5

When executing the code for this exercise you may notice that the decimal point is never lit. This is how I modified the code to test all of the code segments (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, .).

The original code shows a list for 10 decimal number in hexadecimal format:

SEGCODE = [0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f]

To add the decimal point to the end of the list I could have just added the binary 0b1000000 to the list, but, in keeping with the format, I wanted hexadecimal. This was easily found in the micropython shell by entering in:

hex(0b10000000)

This gave me the hexadecimal 0x80 to enter in as the last item in the list.

SEGCODE = [0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x80]

I changed the for loop range at the bottom to 11 from 10 and that was it:

while True:
    for num in range(11):
        hc595_shift(SEGCODE[num]) 
        print(num)
        print("{:0>8b}".format(SEGCODE[num])) 
        print(SEGCODE[num])
        print('')
        time.sleep_ms(200)

The decimal point was already wired in during the lesson so there were no changes necessary to the wiring.

Feel free to reply with code mods you attempted.