def readADC_pico(nn,cnvrt=5.035477e-05): #By D@CC #On 2024BFeb29 #Article: 180.html #uSD: Fla53D #nn is the pico GPnn (ADCnn) to read # if cnvrt is absent: # returns a value from 0 to 3v3 # if cnvrt = 1 # returns the value read from 0 to 65535 # if cnvrt = other # returns a value in range 0 to other*65535 #Functions Used: # Pin() # machine.ADC(nn) # #cnvrt = 5.035477e-05 converts the reading to volts # when the ixProbe is not used . # that is the default cnvrt factor. # next line is needed to remove pull-up resistor # to produce a high-impedance input # Source: forum.micropython.org/viewtopic.php?f=21&t=9959 adcFirst =Pin(nn+26,Pin.IN) # create the ADC object adcFirst = machine.ADC(nn) # now read the ADC adcValue=adcFirst.read_u16() #print("The value of ADC0 is", adcValue) #conversion_factor = 3.3 / (65535) #print("conversion_factor:",conversion_factor) adcVoltage=adcValue * cnvrt #print("The voltage at ADC0 is", adcVoltage) #print("-bye- from readADC_pico.py") return adcVoltage #def end #/readADC_pico.py