Konubinix' opinionated web of thoughts

Analog Input vs Digital Input With Wemos D1

Fleeting

analog input vs digital input with wemos d1

Using a setup similar to this https://randomnerdtutorials.com/esp8266-adc-reading-analog-values-with-nodemcu/

from machine import Pin, ADC
from time import sleep

pot = ADC(0)

while True:
  pot_value = pot.read()
  print(pot_value)
  sleep(0.1)

provides values 3, …, 1024

While plugging on D0 (16, see the pinout)

from machine import Pin
from time import sleep

p = Pin(16, Pin.IN)

while True:
  print(p.value())
  sleep(0.1)

I get only 0 or 1. And the transition from 0 to 1 occurs when pot reads 512, hence the mid value