#adc0_test.py
# dew.ninja  June 2021
# test reading from ADC0 (GPIO36)

from machine import Pin, ADC, PWM
from utime import sleep_ms
PWMMAX = 1023
pwm2 = PWM(Pin(2)) # assign output to pin 2
pwm2.freq(2000)  # set frequency

pwmval = 0  # PWM value
adc = ADC(Pin(34)) #ADC1_CH0
adc.atten(ADC.ATTN_11DB) # range 0 - 3.6 V
while True:
    adcval = adc.read()
    print(adcval)
    pwm2.duty(adcval>>2)
    sleep_ms(1000)