2025-03-22 00:49:46 +01:00

35 lines
770 B
Python

# Import all libs
from machine import PWM, Pin, ADC
import time
# Value definitions
pwm_const = 65535
pwm_percentage = 0.80
# Make calculations on the cont to use it later
cycle = int(pwm_const*pwm_percentage)
# Define pins to use
led_pwm = PWM(Pin(16, mode=Pin.OUT))
adc_pin = Pin(26, mode=Pin.IN)
pin_bpblue = Pin(20, mode=Pin.IN)
pin_bpred = Pin(21, mode=Pin.IN)
# Define parameters
led_pwm.freq(50)
adc = ADC(adc_pin)
# Main loop
led_pwm.duty_u16(cycle)
while True :
etat_BPblue = pin_bpblue.value()
etat_BPred = pin_bpred.value()
N = adc.read_u16();
led_pwm.duty_u16(N)
if (etat_BPred == False) and (etat_BPblue == False):
time.sleep(5)
print(N)
time.sleep(0.01)
'''
pin_led.value(True)
'''