A MicroPython library for a LED matrix using the TM1740 LED driver.
Copy the file to your device, using ampy, webrepl or compiling and deploying. eg.
$ ampy put tm1640.py
Basic usage
import tm1640
from machine import Pin
tm = tm1640.TM1640(clk=Pin(14), dio=Pin(13))
# line from bottom left to top right
tm.write([1, 2, 4, 8, 16, 32, 64, 128])
# all on
tm.write([255, 255, 255, 255, 255, 255, 255, 255])
# all off
tm.write([0, 0, 0, 0, 0, 0, 0, 0])
# all LEDs dim
tm.brightness(1)
# all LEDs bright
tm.brightness(7)
# the number 3
tm.write([0b00000000, 0b00011110, 0b00110011, 0b00110000, 0b00011100, 0b00110000, 0b00110011, 0b00011110])
# cross
tm.write(b'\x81\x42\x24\x18\x18\x24\x42\x81')
# squares
tm.write([255, 129, 189, 165, 165, 189, 129, 255])
# 50% on
tm.write_int(0x55aa55aa55aa55aa)
For more detailed examples, see
- WeMos D1 Mini $3.50 USD
- Clone DIY More WeMos Matrix LED Shield $1.35 USD
- Dual Base for WeMos D1 Mini $1.00 USD
WeMos D1 Mini | TM1640 LED Matrix |
---|---|
D5 (GPIO14) | CLK |
D7 (GPIO13) | DIO |
3V3 (or 5V) | VCC |
G | GND |
- WeMos D1 Mini
- micropython.org
- TM1640 datasheet
- Titan Micro TM1640 product page
- MicroPython framebuf
- Adafruit Ampy
Licensed under the MIT License.