import serial
import time

ser = serial.Serial('/dev/ttyACM0', 19200, timeout=1)


def lightSwitch(numbers):
    toSend = [0b00000000, ] * 4
    if numbers:
        for light in numbers:
            if light >= 0 and light < 32:
                pos = light % 8
                index = light // 8
                toSend[index] = toSend[index] | (0b10000000 >> pos)
            else:
                toSend = [0b00000000, ] * 4
    else:
        toSend = [0b00000000, ] * 4
    ser.write(toSend)


def lightMusic(ls):
    bass = [7, 16, 18, 23, 26, 27]
    midOne = [5, 12, 22]
    midTwo = [15, 2, 3, 4]
    high = [10, 17, 21, 25, 31]
    discoBall = [29, ]
    return (bass * ls[0] + midOne * ls[1] + midTwo * ls[2] + high * ls[3] + discoBall)



@@ -523,16 +523,20 @@
 ss = %5B7,
+ 10,
  16, 18,
@@ -546,16 +546,20 @@
 , 26, 27
+, 28
 %5D%0A    mi
@@ -570,14 +570,21 @@
  = %5B
+1, 
 5, 12,
+ 13,
  22%5D
@@ -624,17 +624,17 @@
 igh = %5B1
-0
+4
 , 17, 21
@@ -651,25 +651,22 @@
     
-discoBall
+constant
  = %5B29
-, 
 %5D%0A  
@@ -743,17 +743,16 @@
 %5D + 
-discoBall
+constant
 )%0A%0A%0A

add new lights