17 lines
391 B
Python
17 lines
391 B
Python
from machine import Pin, PWM
|
|
from time import sleep
|
|
|
|
outPin = 16
|
|
analogOut = PWM(Pin(outPin))
|
|
|
|
analogOut.freq(1000)
|
|
|
|
# 0 off // 65535 full on
|
|
# this means 3.3v is devided by 65535, so you can output
|
|
# continuous voltage
|
|
analogOut.duty_u16(0)
|
|
|
|
while True:
|
|
myVoltage = float(input('What Voltage Would You Like? '))
|
|
pwmVal = int((myVoltage / 3.3) * 65535)
|
|
analogOut.duty_u16(pwmVal) |