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)
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS
rgb1:R
rgb1:COM
rgb1:G
rgb1:B
r1:1
r1:2