005 – MicroPython TechNotes: Gorilla Cell LED | MicroPython Hello World
Table of Contents

In this article, we will look at LED. We will learn on how to control it by turning it ON and OFF. LED stands for Light-Emitting Diode. It is a type of electronic of component that emits light when a sufficient voltage is applied on its terminals.
PINOUT
- G – for the ground pin.
- V – for the supply voltage pin.
- S – for the control signal for the LED. Applying a logic 1 on this pin will turn ON the LED and a logic 0 turn it OFF.
BILL OF MATERIALS
- LED module.
- ESP32 Development board.
- Gorilla ESP32 shield.
- 3-pin female-to-female dupont jump wires.
HARDWARE INSTRUCTION
- Connect ESP32 dev board at the top of ESP32 shield observing correct orientation and alignment.
- Attach a dupont to LED module observing proper color-coding which black wire for the ground, red wire for the VCC, and yellow wire for other signal pins.
- Attach the other side of dupont to ESP32 shield by matching the color-coding of the dupont and the pin headers which black to black, red to red, and other colors to yellow.
- Power up the ESP32 shield by attaching the USB type-C cable.
- Connect the micro USB cable to ESP32 dev board.

SOFTWARE INSTRUCTION
- Open Thonny Python IDE.
- Click “New” to create a new file.
- Copy and paste one of the example source code.
- Save it to your computer in your preferred location. I recommend to create a single folder location for easy reference.
- Click the “Stop” button in Thonny. The triple greater than sign should appear >>>.
- Click the “Run” button to execute the code.
- Enjoy.
VIDEO DEMONSTRATION
CALL TO ACTION
For any concern, write your message in the comment section.
You might also like to support my journey on Youtube by Subscribing. Click this to Subscribe to TechToTinker.
Thank you and have a good days ahead.
See you,
– George Bantique | tech.to.tinker@gmail.com
SOURCE CODE
1. LED Example # 1, turning ON or OFF
from machine import Pin
red = Pin(16, Pin.OUT)
# The following codes should be tested
# using the REPL
red.on() # Turn ON LED
red.off() # Turn OFF LED
red.value(1) # Turn ON LED
red.value(0) # Turn OFF LED
red.value(True) # Turn ON LED
red.value(False) # Turn OFF LED
How the code works
2. LED Example#2, blinking all LED
from machine import Pin
from time import sleep
r = Pin(16, Pin.OUT)
g = Pin(17, Pin.OUT)
b = Pin(18, Pin.OUT)
y = Pin(19, Pin.OUT)
while True:
# Turn ON 'all' LEDs
r.on()
g.on()
b.on()
y.on()
sleep(1)
# Turn OFF 'all' LEDs
r.off()
g.off()
b.off()
y.off()
sleep(1)
How the code works
from time import sleep
r = Pin(16, Pin.OUT)
while True:
3. LED Example#3, running LED
from machine import Pin
from time import sleep
r = Pin(16, Pin.OUT)
g = Pin(17, Pin.OUT)
b = Pin(18, Pin.OUT)
y = Pin(19, Pin.OUT)
# Create the list of led objects
led = [r, g, b, y]
while True:
# Create a loop that will iterate from 0 to 3
for x in range(4):
print(x) # Print the current value of 'x'
led[x].on() # Turn ON current x led
led[x-1].off() # Turn OFF previous x led
sleep(0.5) # Stay in the LED value for a definite time
How the code works