Open VladimirAstrelin opened 1 year ago
Hi @VladimirAstrelin which board are you using the library with?
Dear Sir, I use ESP32-WROOM-32 as I mentioned in the subject to my message. Here's a little more detailed description: ESP32 Type-C CH340 2.4GH Dual Mode WiFi+Bluetooth Dual Core ESP32-WROOM-32 Dev Board Thanks for answering my message. I hope my reply will help. Thanks again for your libraries ! I would like to understand better how they work. Warmest regards, Vlad, Ukraine.
Hi, I meant, which TM16xx board were you trying to use this library with. Not the microcontroller using it.
I use this one:
https://www.aliexpress.com/i/32893633739.html
TM1638 Key Module 8-Bit Digital LED Display Tube Module Board 7 Segment 8 Bits RED TM1638 KEY LED Display Panel
Thanks for your support.
I am using the same board. I just tried your code on mine and it works as expected.
Hopefully they haven't changed any wiring on newer boards. Mine is a few years old now.
You could try power cycling the board:
tm.power(0)
tm.power(1)
tm.led(0,1)
You can try calling tm.write()
to see if it turns the correct LEDs on. It expects a byte array of up to 16 bytes.
byte0 - 1st 7 segment (below LED1)
byte1 - LED1
byte2 - 2nd 7 segment
byte3 - LED2
byte4 - 3rd 7 segment
byte5 - LED3
...
byte14 - 8th 7 segment (right most)
byte15 - LED8
Turn all segments and LEDs on:
tm.write(bytearray([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]))
Turn all segments on, all LEDs off:
tm.write(bytearray([255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0]))
Turn all LEDs on, all segments off:
tm.write(bytearray([0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255]))
# only the LSB is used, so effectively the same as:
tm.write(bytearray([0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1]))
If you press and hold S1
and call tm.keys()
does it give you 1
?
Hold both S1
and S2
and you should get 3
.
1) If you press and hold S1 and call tm.keys() does it give you 1? --- No, it doesn't. It gives zero. What pins on ESP32 do you use for STB, CLK and DIO ? What's the role of STB ? Maybe the problem with keys is about wrong wiring of STB ? 2) LEDs ( LED1...LED8) work fine, Seven-segmen LEDs work fine...but keys do not react...nothing happens when I press them..
Here is the photo on My ESP32 with TM1638 board, as you can see ALL LEDs and 7-segments are working just fine. But keys do not react at all. Here is the link to the photo: https://drive.google.com/drive/folders/11qr3VCV6V0n5WOEQ1qmSY4h-VdYr-_5w?usp=sharing Here is my code:
from time import sleep_ms from machine import Pin import tm1638
tm = tm1638.TM1638(stb=Pin(13), clk=Pin(22), dio=Pin(21))
for i in range(8): tm.led(i, 1) sleep_ms(200)
for i in range(8): tm.led(i, 0) sleep_ms(200)
tm.led(0, 1) tm.led(0, 0)
tm.led(1, True) tm.led(1, False)
tm.leds(8)
tm.leds(7)
for i in range(10): tm.leds(0b01010101) sleep_ms(100) tm.leds(0b10101010) sleep_ms(100)
tm.leds(0)
while True: pressed = tm.keys() for i in range(8): tm.led(i, (pressed >> i) & 1) sleep_ms(10)
STB
is strobe, DIO
is data in/out, CLK
is clock.
I'm using a TinyPICO ESP32 with pins:
tm = tm1638.TM1638(stb=Pin(5), clk=Pin(18), dio=Pin(23))
So it looks like it's mostly working. I think it might be trying to loop too fast. Try increasing the sleep_ms(10) to 500 and see if that works. 10ms works fine on mine. Just trying to rule that out.
Little test I put together, which prints whats happening inside tm.keys()
def test():
tm.stb(0)
tm._byte(66)
for i in range(4):
print(tm._scan_keys())
tm.stb(1)
Press = 4x printed values
S1 = 1 0 0 0
S2 = 0 1 0 0
S3 = 0 0 1 0
S4 = 0 0 0 1
S5 = 16 0 0 0
S6 = 0 16 0 0
S7 = 0 0 16 0
S8 = 0 0 0 16
Dear Sirs, thanks a lot for your great libraries for TM1637 & TM1638. Everything works just fine except keys(buttons) in your library for TM1638.
This piece of code doesn't turn on LEDs on the board. Please let me know what might go wrong. Many thanks in advance, Vlad, Ukraine.