i2c-dev
i2c-bcm2708
are in there(or adding them).
blacklist spi-bcm2708
blacklist i2c-bcm2708
are commented out i.e. #blacklist spi-bcm2708
#blacklist i2c-bcm2708
sudo apt-get install python-smbus
sudo i2cdetect -y 1
sudo i2cdetect -y 0
returned any results :(
wget https://github.com/pimoroni/piglow/blob/master/examples/piglow-example.py
python piglow-example.py
values = [0x01,0x02,0x04,0x08,0x10,0x18,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90,0xA0,0xC0,0xE0,0xFF]
values = [0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0F,0x10,0x11,0x12]
# PiGlow code that creates an animation of the arms steadily increasing in speed
#
# Based on the demo code from: https://github.com/pimoroni/piglow
#
# LEDs are cleared once animation is complete
import time
import sys
from smbus import SMBus
# command register addresses for the SN3218 IC used in PiGlow
CMD_ENABLE_OUTPUT = 0x00
CMD_ENABLE_LEDS = 0x13
CMD_SET_PWM_VALUES = 0x01
CMD_UPDATE = 0x16
class PiGlow:
i2c_addr = 0x54 # fixed i2c address of SN3218 ic
bus = None
def __init__(self, i2c_bus=1):
self.bus = SMBus(i2c_bus)
# first we tell the SN3218 to enable output (turn on)
self.write_i2c(CMD_ENABLE_OUTPUT, 0x01)
# then we ask it to enable each bank of LEDs (0-5, 6-11, and 12-17)
self.write_i2c(CMD_ENABLE_LEDS, [0xFF, 0xFF, 0xFF])
def update_leds(self, values):
print "update pwm"
self.write_i2c(CMD_SET_PWM_VALUES, values)
self.write_i2c(CMD_UPDATE, 0xFF)
# a helper that writes the given value or list of values to the SN3218 IC
# over the i2c protocol
def write_i2c(self, reg_addr, value):
# if a single value is provided then wrap it in a list so we can treat
# all writes in teh(*sic) same way
if not isinstance(value, list):
value = [value];
# write the data to the SN3218
self.bus.write_i2c_block_data(self.i2c_addr, reg_addr, value)
# create an instance of our PiGlow class and tell it that "1" is the I2C bus
# index (should be 0 for old old old Pis)
piglow = PiGlow(1)
# set a block of LEDs and clear them after a delay
def setLeds(ids,delay) :
values=[]
for i in range(0,18) :
values.append(0x00)
for id in ids :
values[id]=0x01 # set this to 0xFF for eye burning brightness
piglow.update_leds(values)
sleep = float(delay)/10
time.sleep(sleep)
values = [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
piglow.update_leds(values)
for delay in range (8,0,-1) :
ids=[0,1,2,3,14,12]
setLeds(ids,delay)
ids=[17,16,15,13,11,10]
setLeds(ids,delay)
ids=[4,5,6,7,8,9]
setLeds(ids,delay)
# add 10 extra spins at high speed for fun
for counter in range (0,10) :
ids=[0,1,2,3,14,12]
setLeds(ids,0.5)
ids=[17,16,15,13,11,10]
setLeds(ids,0.5)
ids=[4,5,6,7,8,9]
setLeds(ids,0.5)
email
root
flog archives
In fact I'm not responsible for anything ever, so there!
Disclaimer:
This page is by me for me, if you are not me then please be aware of the following
I am not responsible for anything that works or does not work including files and pages made available at www.jumpstation.co.uk
I am also not responsible for any information(or what you or others do with it) available at www.jumpstation.co.uk