# Esp32 - Driver for potentiometer ADC on kit FKS0001
# provided by Anthony Vogelaar, Perth Scotland
# rev 0.10  2025-06-19  initial release

from 	machine 	import 	ADC, freq;		freq(240_000_000)
import	time

# Implemented:
# potmInit(pin=26)
# potmGet()         -->  float

# ====================== Potmeter ADC ==========================

potm = None

# Setup ADC channel potentiometer
def potmInit(pin=26):
    global potm
    potm = ADC(pin, atten=ADC.ATTN_11DB)
    

# get potentiometer voltage 0.128 .. 3.126 Volt
def potmGet():
    return round(potm.read_uv()/1_000_000, 3)
    
# ========================== Test ==============================
    
def test():
#    print (__name__)
    potmInit()
    while True:
        print(potmGet(), 'Volt')
        time.sleep(1)
        
        
test()

# ===================== End =========================
