Adsense HTML/JavaScript

Friday, August 14, 2020

Simple digital input/output on ESP32/MicroPython

 


A simple exercise of digital input/output on ESP32/MicroPython, digitalIn.py.

from machine import Pin
from time import sleep

LED2 = Pin(2, Pin.OUT)
IN32 = Pin(32, Pin.IN, Pin.PULL_UP);

while True:
    v = IN32.value()
    LED2.value(v)
    print(v)
    sleep(0.1)

  • Note that GPIO6-11 are usually used for SPI flash.
  • GPIO34-39 can only be set as input mode and do not have software pullup or pulldown functions.


No comments:

Post a Comment