Well the LEDs work a treat too (datasheet). The following code cycles through each LED as shown in the video:
#!/usr/bin/python
import smbus
from time import sleep
bus = smbus.SMBus(1) # 0 = /dev/i2c-0 (port I2C0), 1 = /dev/i2c-1 (port I2C1)
LED_ADDRESS = 0x60 #7 bit address without r/w bit (will be left shifted automatically)
i = 0
while (1):
bus.write_i2c_block_data(LED_ADDRESS, 0x15,[ 0x02, 0x00 ])
if (i == 0): bus.write_i2c_block_data(LED_ADDRESS, 0x15,[ 0x01, 0x00 ]) #LED 0 = on
if (i == 1): bus.write_i2c_block_data(LED_ADDRESS, 0x15,[ 0x04, 0x00 ]) #LED 1 = on
if (i == 2): bus.write_i2c_block_data(LED_ADDRESS, 0x15,[ 0x10, 0x00 ]) #LED 2 = on
if (i == 3): bus.write_i2c_block_data(LED_ADDRESS, 0x15,[ 0x40, 0x00 ]) #LED 3 = on
if (i == 4): bus.write_i2c_block_data(LED_ADDRESS, 0x15,[ 0x00, 0x01 ]) #LED 4 = on
if (i == 5): bus.write_i2c_block_data(LED_ADDRESS, 0x15,[ 0x00, 0x04 ]) #LED 5 = on
if (i == 6): bus.write_i2c_block_data(LED_ADDRESS, 0x15,[ 0x00, 0x10 ]) #LED 6 = on
if (i == 7): bus.write_i2c_block_data(LED_ADDRESS, 0x15,[ 0x00, 0x40 ]) #LED 7 = on
i = i + 1
if (i == 8): i = 0
sleep(1)
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.