Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Hardware access, the General Purpose Input Output (GPIO) pins.Running the programs on the PC | ||||||||
Line: 31 to 30 | ||||||||
In order to understand how to access GPIO line we must look up the MicroPython documentation. Select Quick reference for the ESP32 and search for Pins and GPIO . | ||||||||
Changed: | ||||||||
< < | As you can see, MicroPython supplies a Python module named Pin, which is used to program GPIO pins. In order to control a LED the corresponding pin must be programmed to be an output line. | |||||||
> > | The schematic diagram of the LED connection looks like this: | |||||||
Added: | ||||||||
> > | When the output level on GPIO 2 is zero, then there is no voltage across the LED and the resistor. The LED is switched off. If GPIO 2 is at high level, then there is a voltage of 3.3V across the LED and the resistor and the LED lights up. The 330 Ω resistor limits the current flowing through the LED to 10 mA. As you can see, MicroPython supplies a Python module named Pin, which is used to program GPIO pins. In order to control a LED the corresponding pin must be programmed to be an output line. | |||||||
from machine import Pin from time import sleep led = Pin(2,Pin.OUT) # the led is connected to GPIO 2 and this is an output line | ||||||||
Line: 53 to 58 | ||||||||
| ||||||||
Added: | ||||||||
> > |
|