from machine import Pin, ADC
from time import sleep

led0 = Pin(32, Pin.OUT)
led1 = Pin(33, Pin.OUT)
led2 = Pin(25, Pin.OUT)
led3 = Pin(26, Pin.OUT)
led4 = Pin(27, Pin.OUT)

adc = ADC(Pin(2))
adc.atten(ADC.ATTN_11DB)
adc.width(ADC.WIDTH_9BIT)

while True:
  adc_value = adc.read()
  volts = int((adc_value*31)/511)
  binary = '{0:05b}'.format(volts)
  
  input_voltage = "the voltage is {:2d} volts and the raw value is {:4d} and the binary value is"
  print(input_voltage .format(volts, adc_value), binary, end = "\r")

  led0.value(int(binary[4]))
  led1.value(int(binary[3]))
  led2.value(int(binary[2]))
  led3.value(int(binary[1]))
  led4.value(int(binary[0]))
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
led4:A
led4:C
led5:A
led5:C
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2
r4:1
r4:2
r5:1
r5:2
pot1:GND
pot1:SIG
pot1:VCC