From 87f1ce2ef934d476ceb715bc291fcb5a274d3bba Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Tue, 20 Sep 2016 00:08:31 +0200 Subject: initial commit --- Raspberry Pi/python copy.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Raspberry Pi/python copy.py (limited to 'Raspberry Pi/python copy.py') diff --git a/Raspberry Pi/python copy.py b/Raspberry Pi/python copy.py new file mode 100644 index 0000000..6a53c02 --- /dev/null +++ b/Raspberry Pi/python copy.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 """ + -- cgit v1.2.3