# read the temperature value from Analog Temperature Sensor(NTC), and control the speed of an fan
# that is directly proportional to the temperature, Use an LED , that brightness is directly
# related to the fan speed, as a fan.
from machine import Pin, ADC, PWM
import time
ntc_pin=ADC(Pin(34))
led_pin=PWM(Pin(32))
while True:
temp_val=ntc_pin.read_u16()
print(temp_val)
led_pin.duty_u16(temp_val)
#ratio formula: o/p=((i/p-i/p_min)x(o/p_max-o/p_min)/(i/p_max-i/p_min))+o/p_min
#relationship between (61022-7393)
# & (1023-0), where temp_val is input.
out_value=int((temp_val-7393)*1023/53629)
print(out_value)
time.sleep(0.5)