4. Embedded Programming
This week is my introduction to microcontrollers and creating codes to operate them. So far the most I have done regarding coding is doing very basic commands in Scratch. Even then, the outcomes weren’t great. For this week’s assignment, I will be learning about the Seeed Xiao RP2040 and the Xiao ESP32-C3 which are the micro controllers I intend to use in my final project. I hope to use the knowledge from this week to inform how best to integrate my coding and hardware for the coming weeks.
Week 4 Group AssignmentSeeed Xiao RP2040 Datasheets and Specifications
Seeed Xiao ESP32-C3 Datasheets and Specifications
Hardware Testing
The goal for this assignment was to make a blinking LED. To start the assignment I turned to my friend ChatGPT as I had no idea how to begin otherwise. My prompt was: please write a micropython code to make a LED blink using an RP2040 microcontroller on a breadboard.
Which resulted in the following response:
Link to ChatGPTHere’s a simple MicroPython example to blink an LED using an RP2040 (such as a Raspberry Pi Pico) on a breadboard.
Hardware setup
-RP2040 board (e.g. Raspberry Pi Pico)
-LED
-220–330 Ω resistor
-Breadboard + jumper wires
Wiring:
-GPIO 15 → Resistor → LED anode (long leg)
-LED cathode (short leg) → GND
(You can change the GPIO pin in the code if needed.)
MicroPython LED Blink Code
from machine import Pin
import time
# Set up the LED pin (change 15 if using a different GPIO)
led = Pin(15, Pin.OUT)
while True:
led.value(1) # Turn LED ON
time.sleep(0.5) # Wait 0.5 seconds
led.value(0) # Turn LED OFF
time.sleep(0.5) # Wait 0.5 seconds
How it works (quick explanation)
-Pin(15, Pin.OUT) sets GPIO 15 as an output pin
-led.value(1) supplies 3.3V → LED turns on
-led.value(0) cuts power → LED turns off
-time.sleep() controls the blink speed
Tips
-To blink faster or slower, adjust the sleep() values
-If your LED doesn’t light up, flip it around (polarity matters)
You can use the onboard LED instead by replacing the pin line with:
led = Pin("LED", Pin.OUT)
If you want, I can also:
-Add PWM fading
-Blink multiple LEDs
-Rewrite this for Thonny upload workflow
-Or adapt it for a custom RP2040 board
It took me way too long to make sense of everything ChatGPT was telling me so I decided to assemble the list of components it gave me.
Thankfully my lab had some used microcontrollers, pinned LEDs, breadboards, jumper wires, resistors and a multimeter. I also picked up a 3V cell battery and a few strips of copper tape to add to my experimenting.
ChatGPT said that I would need a 220-330 Ω resistor. I was able to decode the marking on the container of resistors I found in the lab and tested them with the multimeter to ensure I was using the right ones. I noted from my test that these seemed to be approximate values as the actual values I got were 219.1Ω and 326.9Ω
In my day job as a STEAM FabLab Educator, I teach kids about simple circuits both in parallel and series configurations. I was trying to see if that experience could help me build a basic understanding of how the breadboard works and the flow of electricity from positive to negative. My first test worked very well. I got the LED to light up and everything made sense. In the image you can also see how I connected the jumper wires to the battery using the conductive tape.
The big difference came when I tried using the resistors. The LED wouldn't turn on with the resistor and my best guess was that the power source was not strong enough to need a resistor and that the reduced power was too week to light the LED. Through other tests, I learned that LEDs of different colors have different power requirements. Red, green and yellow lights were easier to power, while white and blue needed more electricity.
Next I tried connecting the microcontrollers to my computer. I mentioned before that they were used and I didn’t know what they were programmed to do or if they even worked. To my surprise, they lit up and I could actually play with them. That said, I still didn’t know how to play with them.
Failing to Understand Programming
To dive deeper into the world of these microcontrollers, I needed to look at all of my available information simultaneously. The videos got me onto Thonny for the Micropython, I tried to understand the pinouts for the RP2040 and I crossreferenced the ChatGPT for more guidance… It didn’t work. I just got extremely overwhelmed and confused by the whole process.
Understanding the Concepts with Microbits
I did a hard pivot to the only form of coding I knew. Scratch was also a bad idea because I couldn’t get my Microbit to connect. This is a good time to mention that I was given a free microbit a few weeks before at the hack night event that happened in the lab.
Pivoting again, I decided to look into microbits and see if I could connect to a dedicated site for the controllers. I was so excited to find that Microsoft hosts a microbit site that was actually very easy to use https://makecode.microbit.org.
I started the code by using the ‘On button A pressed’ and ‘On button B pressed’ input components. Then, I added the ‘Show LED’ component to each input. For the ‘A’ input, I created an ‘A’ shape in the square grid. I did the same in the ‘B’ input swapping the ‘A’ shape for ‘B’.
Link to Microbit Code
When I finished my first 2 commands, I created a new input ‘On button A+B pressed’ with the prompt ‘Show string “Hello!”’I was then able to download my code to the microbit and test the output.