I recently brought some of these rather nice Texas
Instruments TIL311 hexadecimal displays from eBay, they are really small but beautiful. This got me thinking, could I connect one of these
displays to a micro:bit.
TIL311 Displays |
Looking at the TIL311 datasheet, I came across the first hurdle.
The TIL311 is a TTL device and needs 5v
to work but the micro:bit runs at 3.3v so I needed a level shifter / buffer IC
to interface between them, you could probably get away without a level shifter
but I aired on the safe side. I chose the 74HCT244N but I used a 74HC244N as this
is what I had in stock.
The TIL311 has a 4-bit data input A,B,C,D which I connected to pins 0,1,2 & 8 on
the micro:bit via a 74HCT244N and used separate 5v supply for the display. To figure out how to display 0 to 9 I
looked at the truth table for a 7490 decade counter and then replicated this in
Python by turning the outputs on and off.
The finished project |
My rather noddy Python code, I'm sure there must be a neater way of doing this.
- from microbit import *
- pins = [pin0, pin1, pin2, pin8]
- while True:
- 0#
- pin0.write_digital(0)
- pin1.write_digital(0)
- pin2.write_digital(0)
- pin8.write_digital(0)
- 1#
- pin0.write_digital(1)
- pin1.write_digital(0)
- pin2.write_digital(0)
- pin8.write_digital(0)
- sleep(500)
- 2#
- pin0.write_digital(0)
- pin1.write_digital(1)
- pin2.write_digital(0)
- pin8.write_digital(0)
- sleep(500)
- 3#
- pin0.write_digital(1)
- pin1.write_digital(1)
- pin2.write_digital(0)
- pin8.write_digital(0)
- sleep(500)
- 4#
- pin0.write_digital(0)
- pin1.write_digital(0)
- pin2.write_digital(1)
- pin8.write_digital(0)
- sleep(500)
- 5#
- pin0.write_digital(1)
- pin1.write_digital(0)
- pin2.write_digital(1)
- pin8.write_digital(0)
- sleep(500)
- 6#
- pin0.write_digital(0)
- pin1.write_digital(1)
- pin2.write_digital(1)
- pin8.write_digital(0)
- sleep(500)
- 7#
- pin0.write_digital(1)
- pin1.write_digital(1)
- pin2.write_digital(1)
- pin8.write_digital(0)
- sleep(500)
- 8#
- pin0.write_digital(0)
- pin1.write_digital(0)
- pin2.write_digital(0)
- pin8.write_digital(1)
- sleep(500)
- 9#
- pin0.write_digital(1)
- pin1.write_digital(0)
- pin2.write_digital(0)
- pin8.write_digital(1)
- sleep(500)