diff options
Diffstat (limited to 'Raspberry Pi')
-rw-r--r-- | Raspberry Pi/config.json | 0 | ||||
-rw-r--r-- | Raspberry Pi/python.py | 18 |
2 files changed, 12 insertions, 6 deletions
diff --git a/Raspberry Pi/config.json b/Raspberry Pi/config.json new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Raspberry Pi/config.json diff --git a/Raspberry Pi/python.py b/Raspberry Pi/python.py index 9189f8e..bdb939e 100644 --- a/Raspberry Pi/python.py +++ b/Raspberry Pi/python.py @@ -1,22 +1,27 @@ """ Imports """ +import logging import smbus import time +import json import i2cPixel """ Decalrations """ -pixels = 10 +pixels = 72 # Change this to the appropriate number for your setup def hexToRgb(value): value = value.lstrip('#') lv = len(value) return tuple(int(value[i:i+lv/3], 16) for i in range(0, lv, lv/3)) -def main(): +def setup(): + # Get settings from config.json """ Setup i2c communication """ i2cPixel.version() i2cPixel.setBus(1) i2cPixel.setAddress(0x04) + +def main(): """ Wait for heartbeat from Arduino """ while True: @@ -24,16 +29,17 @@ def main(): print "Arduino is Online" break -while True: - test = raw_input() + while True: + test = raw_input() colour = hexToRgb(test) i = 0 - while i < 10: + while i < pixels: i2cPixel.setPixel(i, colour[0], colour[1], colour[2]) i = i + 1 i2cPixel.showPixel() """ Start script """ -main() +setup() #configure +main() #Start main |