aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Stendahl <JakobS1n@users.noreply.github.com>2016-09-23 07:35:31 +0200
committerGitHub <noreply@github.com>2016-09-23 07:35:31 +0200
commit77ac60b5a29829bf8d2522d6cac0ce8120009b93 (patch)
tree786c9cf8fda78b7a6b01e04e0c818aecd4f9301c
parentde76400657d7c5e164e2afcddc2f10728b9478e1 (diff)
downloadi2c-Neopixel-77ac60b5a29829bf8d2522d6cac0ce8120009b93.tar.gz
i2c-Neopixel-77ac60b5a29829bf8d2522d6cac0ce8120009b93.zip
Update i2cPixel.py
-rw-r--r--Raspberry Pi/i2cPixel.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/Raspberry Pi/i2cPixel.py b/Raspberry Pi/i2cPixel.py
index 6a53c02..788c771 100644
--- a/Raspberry Pi/i2cPixel.py
+++ b/Raspberry Pi/i2cPixel.py
@@ -15,7 +15,7 @@ def setBus(n):
def greeting():
""" Send heartbeat """
bus.write_byte(arduinoAddress, 0x01)
-
+
""" Wait for response """
try:
response = bus.read_byte(arduinoAddress)
@@ -25,21 +25,26 @@ def greeting():
returnMsg = False
except:
returnMsg = False
- """ Return if heartbeat was received """
+ """ 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():
+def show():
bus.write_byte(arduinoAddress, 0x03)
def waitForSensor():
-
+
while True:
try:
sensorData = bus.read_byte(arduinoAddress)
- if sensorData = 0x02:
- """ sjekk hvilken sensor """
-
+ if sensorData == 0x02:
+ print "SENSOR 1"
+ break;
+ if sensorData == 0x03:
+ print "SENSOR 2"
+ break;
+ except Exception:
+ pass