Display-O-Tron 3000 and Python3
I prefer using Python3 over Python2 for my tinkering and when I first got a Dot3k I remember it needed a lot of fiddling in the bowels of Python to get it working. With a recent re-assignment of my various Raspberry Pi devices, I’ve moved my Dot3k to a new Pi2 with a recent Rasbian and firmware (kernel version 4.0.9-v7+) so thought I’d document the steps needed to get the Dot3k going under Python3.
It was pleasantly straightforward…
First I followed the steps here: http://learn.pimoroni.com/tutorial/display-o-tron/getting-started-with-display-o-tron to get the device going under Python2.7.
Then the following steps got me going under Python3, too:
1 - Install pip for python3:
sudo apt-get install python3-pip
2 - Use pip3 to fetch dot3k into the Python3 modules library:
sudo pip-3.2 install dot3k
3 - To control the various LEDs on the Dot3k from Python3, we need the Python3 version of smbus:
sudo apt-get install python3-smbus
4 - Test the basics:
$ sudo python3
>>> import dot3k.lcd as lcd
>>> import dot3k.backlight as bl
>>> lcd.write(‘Hello,world of Python3!’)