Displayotron-3k-hat countdown timer


Hi recently purchased a Dothat, teaching myself python partly by taking things apart and re-making them with the dothat.

I started out by making a small script to operate the dothat as a torch. This works but I then wanted to make it operate and show a countdown timer while the lights were lit.

This is what I have, it is adapted from a basic countdown script form a few google searches. It works in the IDLE using print in place of lcd.write


In my nativity I thought I could swap out print for lcd.write this approach works in the final “goodbye” line of code which does print to the screen but the count down does not.

Please be gentle to those of you who know what you are doing im sure this is a very simple question of improper syntax … possibly but im lost all the same.


Try: lcd.write(str(count))

This should coerce the count into a string, otherwise it might be interpreted as a character index.

The characters the LCD can theoretically display are on page 5 of this datasheet: http://www.lcd-module.de/pdf/doma/dog-m.pdf

Characters 0 through 7 are all blank by default, so counting down 3, 2, 1 would result in… nothing at all.

Fantastically confusing little syntax niggle to come across, though! I’m not surprised it had you stumped.


Thanks Phil.

Well I’m glad in a way. when I get a chance today I’ll try it. with
reference toy 321 are you saying the characters will not display ?

I’m sure I’ll have more questions once I try this. my plan is to set it up
so I can trigger the “torch” and show a countdown from 30 on screen. simple
stuff but so far just fiddling with these examples that come with the
Dothat I’ve learned allot.

thanks again


The character indexes 0, 1, 2, 3, 4, 5, 6 and 7 are user characters, used for custom icons or animations. By default they’re blank, so if you try something like: lcd.write(0) then it will display, but since it’s blank you wont be able to see it.

The actual numbers 0, 1, 2, 3, 4, 5, 6 etc are at indexes 48, 49, 50, 51.

So if you lcd.write("0") that’s the same as running lcd.write(48).

You can convert between characters and their ordinals/indexes quite easily in Python, like so (this is in a Python repl):

>>> ord("1")


>>> chr(48)

These are super useful things to remember, since characters are always represented as numbers in computers.

This is also why in some examples you’ll see something like lcd.write("Such icon!:" + chr(0)"), this is deliberately writing out the first user character, because it contains some custom artwork.


Very helpful, I’ll try and remember. The count down works well and I have
added backlight.set_graph (1) to enable the light for 30 seconds also with
success. I now need to wrangle with the position of text and work out how
to make it scroll across the first line of the display and have the
countdown of the 2nd line.


OK here is the finished torch.py which included the countdown script resolved in this thread in case anyone is interested.

A strange thing occurs when choosing a different cursor position it causes the printed text to jump lines? although the combination of positions i have in tis code seem to present themselves nicley.

torch.py[quote=“arborowen, post:6, topic:2910”]