From 77ac60b5a29829bf8d2522d6cac0ce8120009b93 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Fri, 23 Sep 2016 07:35:31 +0200 Subject: Update i2cPixel.py --- Raspberry Pi/i2cPixel.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'Raspberry Pi/i2cPixel.py') 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 -- cgit v1.2.3