import time
from machine import ADC ,Pin
import math
DP = Pin (7, Pin.OUT)
dig_1= Pin (8, Pin.OUT)
dig_2= Pin (9, Pin.OUT)
dig_3= Pin (10, Pin.OUT)
dig_4= Pin (11, Pin.OUT)
LET_A= Pin (0, Pin.OUT)
LET_B= Pin (1, Pin.OUT)
LET_C= Pin (2, Pin.OUT)
LET_D= Pin (3, Pin.OUT)
LET_E= Pin (4, Pin.OUT)
LET_F= Pin (5, Pin.OUT)
LET_G= Pin (6, Pin.OUT)
sensor = ADC(Pin(26))
reading_1 = sensor.read_u16()
button = Pin (16, Pin.OUT)
BUTTON_PRESSED = 0
displaycodes = [
0xC0,
0xF9, #1
0xA4, #2
0xB0, #3
0x99, #4
0x92, #5
0x82, #G
0xF8, #7
0x8e, #8
0x90 #9
]
def read_potentiometer():
analog_value1 = sensor.read_u16()
def read_ntc() :
analog_value = sensor.read_u16()
BETA = 3950000
celsius = 1 / (math.log(1 / (65535 / analog_value - 1)) / BETA + 1.0 / 298.15) - 273.15
return (analog_value,1)
while True :
x = read_ntc()
voltage = x * 3.3 / 65535
print("voltage : {:.1f} V".format(voltage))
time.sleep(1)