import time
import math
from machine import Pin, PWM
time.sleep(0.1) # Wait for USB to become ready
rLED = Pin(2, Pin.OUT)
gLED = Pin(3, Pin.OUT)
bLED = Pin(4, Pin.OUT)
'''
# Make common anode connected to 3.3V
# Pins are connected to cathodes
rLED = PWM(Pin(2))
gLED = PWM(Pin(3))
bLED = PWM(Pin(4))
#Frequency is how often they will turn on and off
rLED.freq(1000)
gLED.freq(1000)
bLED.freq(1000)
# 0 is on, max is off for common anode
maxdu16 = 65535
def makeRed(rP):
rLED.duty_u16(maxdu16 - (math.ceil(maxdu16*(rP/100))))
def makeGreen(gP):
gLED.duty_u16(maxdu16 - (math.ceil(maxdu16*(gP/100))))
def makeBlue(bP):
bLED.duty_u16(maxdu16 - (math.ceil(maxdu16*(bP/100))))
'''
colors = ['white', 'red','blue','green','yellow','cyan','purple', 'off']
redP = [1, 1, 0, 0, 1, 0, 1, 0]
greenP = [1, 0, 0, 1, 1, 1, 0, 0]
blueP = [1, 0, 1, 0, 0, 1, 1, 0]
for i in range(len(colors)):
print('color: '+colors[i])
rLED.value(redP[i])
gLED.value(greenP[i])
bLED.value(blueP[i])
time.sleep(1)