/
plate.py
49 lines (40 loc) · 1.24 KB
/
plate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python
from time import sleep
from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
from Adafruit_MCP230xx import MCP230XX_GPIO
from Adafruit_CharLCD import Adafruit_CharLCD
# Initiate CharLCDPlate
led = Adafruit_CharLCDPlate()
# clear screen
led.clear()
# turn LED off
led.backlight(led.OFF)
# Initiate Display
bus = 1 # Note you need to change the bus number to 0 if running on a revision 1 Raspberry Pi.
address = 0x20 # I2C address of the MCP230xx chip.
gpio_count = 8 # Number of GPIOs exposed by the MCP230xx chip, should be 8 or 16 depending on chip.
mcp = MCP230XX_GPIO(bus, address, gpio_count)
# Initialize the LCD plate. Should auto-detect correct I2C bus. If not,
# pass '0' for early 256 MB Model B boards or '1' for all later versions
lcd = Adafruit_CharLCD(pin_rs=1, pin_e=2, pins_db=[3,4,5,6], GPIO=mcp)
# turn lcd off
lcd.display()
# prepare next message and set LED red
led.clear()
led.message("ahutest")
led.backlight(led.RED)
# turn lcd back on
lcd.noDisplay()
sleep(3)
# change lcd mesasge
led.clear()
led.autoscroll()
led.message("Daniel ist doof! super doof! mega doof! hyper doof!")
led.autoscroll()
sleep(3)
led.backlight(led.GREEN)
sleep(3)
# turn lcd and led off
led.backlight(led.OFF)
lcd.display()
sleep(3)