##
##
from machine import Pin
import machine
import time
time.sleep(0.1) # Wait for USB to become ready
ledRed=Pin(15,Pin.OUT)
ledYellow=Pin(14,Pin.OUT)
ledGreen=Pin(13,Pin.OUT)
potPin=28
myPot=machine.ADC(potPin)
while True :
adcRead=myPot.read_u16()
potValue=round((adcRead/65535),2)*100.0
ledsOn=0
ledsOn=ledsOn+(potValue<=79)*1
ledsOn=ledsOn+(potValue>=80 and potValue<=94)*2
ledsOn=ledsOn+(potValue>=94 and potValue<=100)*4
ledRed.value(ledsOn==4)
ledYellow.value(ledsOn==2)
ledGreen.value(ledsOn==1)
time.sleep(0.5)