-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab4
37 lines (25 loc) · 879 Bytes
/
lab4
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
#!/usr/bin/python3
#
# Josie Bunnell (josephinebunnell@bennington.edu ; Sky Leilani (skyleilani@bennington.edu)
#
# 3.26.2019
# import RPi.GPIO as GPIO
# GPIO.setmode(GPIO.BOARD)
import smbus
bus = smbus.SMBus(1)
DEVICE_ADDRESS = 0x70
CONFIG_REGISTER = 0x21
DISPLAY_SETUP = 0x81
DISPLAY_ADDRESS = 0x0 . #0x00 for 1st digit, 0x02 for 2nd digit, 0x04 for colon, 0x06 for 3rd digit, 0x08 for 4th digit
def set_clock(bus):
config_byte = CONFIG_REGISTER
bus.write_byte(DEVICE_ADDRESS, config_byte)
def turn_on_display(bus):
config_byte2 = DISPLAY_SETUP
bus.write_byte(DEVICE_ADDRESS, config_byte2)
def display_data(bus):
config_byte3 = [0b01111111] # 1 in front to turn on decimal, 0 in front for off decimal
bus.write_i2c_block_data(DEVICE_ADDRESS, DISPLAY_ADDRESS, config_byte3)
set_clock(bus)
turn_on_display(bus)
display_data(bus)