analogIn_PWMOut.py

Hookup Pattern

force_analogIn_PWMOut

  1. Connect Sensor Pin3 to ESP32 3V
  2. Connect Sensor Pin2 to ESP32 34
  3. Connect Resistor Pin2 to ESP32 GND
  4. From pin 27, connect the following in series: a Resistor to an LED to GND

Follow along on your ESP32

For Example

# analog in to pwm...

Analog to Digital Conversion (ADC)

Analog to Digital Conversion (ADC) is the process of converting a varying voltage (analog) to a sequence of discrete voltages (digital). MicroPython provides a convenient interface for this via ADC, which can be used on any pin whose number is prep...

for loops

for loops allow one to iterate (repeat) over a collection or sequence. Abstractly all for loops share this structure:

for item in collection:
  do something

But its often easier to understand them in action.

For Example

x = "Mary had a little lamb"
x = x.split(' ')

for i in x...

A voltage divider is a circuit that produces an output that is smaller than its input (where the output is voltage or current).

voltage_divider

The above schematic represents the most basic way to use two resistors (labeled as Z1 and Z2) to take some voltage (Vin) and output a fraction of it (Vout). The...

analog_read.py

# analog read

from machine import ADC, Pin
from time import sleep_ms

adc = ADC(Pin(34))
adc.atten(ADC.ATTN_11DB)

while True:
    print(adc.read())
    sleep_ms(20)

Hookup Pattern

analog_read

  1. Connect Pot1 to ESP32 GND
  2. Connect Pot2 to ESP32 34
  3. Connect Pot3 to ESP32 3V