aboutsummaryrefslogtreecommitdiff
path: root/Raspberry Pi/i2cPixel.py
diff options
context:
space:
mode:
authorJakob Stendahl <jakob@Jakobs-MacBook-Pro.local>2016-09-20 00:09:45 +0200
committerJakob Stendahl <jakob@Jakobs-MacBook-Pro.local>2016-09-20 00:09:45 +0200
commit1b9289759f68535a8a7d8525897f3be60767c479 (patch)
tree5b5df6a39ef0775564c4ba911d64b2dd7eff1b49 /Raspberry Pi/i2cPixel.py
parent87f1ce2ef934d476ceb715bc291fcb5a274d3bba (diff)
downloadi2c-Neopixel-1b9289759f68535a8a7d8525897f3be60767c479.tar.gz
i2c-Neopixel-1b9289759f68535a8a7d8525897f3be60767c479.zip
Filename Update
Diffstat (limited to 'Raspberry Pi/i2cPixel.py')
-rw-r--r--Raspberry Pi/i2cPixel.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/Raspberry Pi/i2cPixel.py b/Raspberry Pi/i2cPixel.py
new file mode 100644
index 0000000..6a53c02
--- /dev/null
+++ b/Raspberry Pi/i2cPixel.py
@@ -0,0 +1,45 @@
+import smbus
+import time
+
+def version():
+ print "i2cPixel is Version 1.0.0"
+
+def setAddress(address):
+ global arduinoAddress
+ arduinoAddress = address
+
+def setBus(n):
+ global bus
+ bus = smbus.SMBus(n)
+
+def greeting():
+ """ Send heartbeat """
+ bus.write_byte(arduinoAddress, 0x01)
+
+ """ Wait for response """
+ try:
+ response = bus.read_byte(arduinoAddress)
+ if response == 0x01:
+ returnMsg = True
+ else:
+ returnMsg = False
+ except:
+ returnMsg = False
+ """ Return if heartbeat was received """
+ return returnMsg
+
+def setPixel(n, red, green, blue):
+ """ Send values for switching a pixel on """
+ bus.write_block_data(arduinoAddress, 0x02, [n, red, green, blue])
+
+def showPixel():
+ bus.write_byte(arduinoAddress, 0x03)
+
+def waitForSensor():
+
+ while True:
+ try:
+ sensorData = bus.read_byte(arduinoAddress)
+ if sensorData = 0x02:
+ """ sjekk hvilken sensor """
+