W4 | Embedded Programming
INDIVIDUAL ASSIGNMENT
- Browse through the data sheet for your microcontroller.
- Write a program for a microcontroller, and simulate its operation, to interact (with local input &/or output devices) and communicate (with remote wired or wireless connection).
- Looking for a Microcontroller ๐
- Here some of its key features:
- 1ร UART: serial communication port
- 1ร IยฒC: device communication
- 1ร SPI: high-speed serial for peripherals
- 11ร GPIOs (PWM)
- 9ร ADC: analog-to-digital inputs
- Reset button
- Boot button (special boot modes / firmware)
- Input voltage (USB-C): 5 V
- Input voltage (BAT): 4.2 V
- Charging current: 100 mA
- Complete 2.4 GHz Wi-Fi subsystem
- BLE: Bluetooth 5.0, Bluetooth mesh
- On-chip 8 MB PSRAM & 8 MB Flash
- Onboard microSD slot (up to 32 GB FAT)
- List of pins โ XIAO ESP32S3 / XIAO ESP32S3 Sense:
- Testing with Different Microcontrollers
-
I navigated to
File > Preferencesand added the following URL to the Additional Boards Manager URLs field:
- Here is the example:
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

-
I went to
Tools > Board > Boards Manager..., searched for "RP2040", selected the latest version of "Raspberry Pi Pico/RP2040", and installed it. - Here is the example:
- After installing the board package, I navigated to
Tools > Board, found "Seeed Studio XIAO RP2040", and selected it. - Here are the examples:
- Find suitable images:
It is recommended to use black-and-white images to simplify conversion and improve compatibility with the OLED screen. - Resize the image:
Adjust the image dimensions to fit the OLED screen resolution, ensuring that details remain visible. Paint or any image editing software can be used. - Convert to BMP format:
Save the image as a monochrome BMP file to facilitate conversion to hexadecimal code. - Here is the example:
- Generate hexadecimal code:
After converting the image to black and white and resizing it to fit the OLED screen, the next step is to use the image2cpp tool to convert the BMP image into a hexadecimal number matrix that the microcontroller can interpret. - These are the settings that have been modified; the rest remain at their default values.
- Then, the code is generated.
- Here is the example:
- This code is a section of the final program that will be used and uploaded through the Arduino IDE platform. ๐
- Install the necessary libraries:
Install the required libraries to use the OLED screen (e.g., Adafruit GFX, Adafruit SSD1306). - Import the generated hexadecimal code:
Copy the hexadecimal matrix generated by image2cpp into the Arduino code. - Connect the OLED display to the microcontroller:
Use the following connections:- GND to ground
- VCC to 3.3V
- SDA to pin A4
- SCL to PIN A5
- Adapt the code for the project:
Modify the code to fit the desired functionality. - You can view the simulation at the following link: PANDA WOKWI
- Here is the result: ๐
After exploring different microcontrollers (and discarding a few along the way), I've chosen the one that perfectly
fits the needs of my little robot. And the winner is ... drumroll 🥁 ... The Seeed Studio XIAO ESP32S3 Sense!
This microcontroller has everything required to make my little robot come to life.

XIAO ESP32S3 Sense
XIAO ESP32S3 SENSE DATA SHEET
The table below summarizes the main key features of the microcontroller. More detailed information can be found at the link provided below. Seed Studio Web Page
Features |
Description |
|---|---|
| Processor | ESP32-S3R8 Xtensa LX7 dual-core, 32-bit processor (up to 240 MHz) |
| Built-in Sensors | OV2640 camera sensor (1600 ร 1200) |
| Interface |
|
| Power |
|
| Wireless |
|
| Memory |
|
| Software Compatibility | Arduino IDE, MicroPython |
| Power Supply & Downloading Interface | USB Type-C interface |

๐Note: One of the greatest advantages of this microcontroller is its built-in camera, which can capture images for AI training โ a feature I'd love to include in my robot. However, even if I later decide to design the robot without a camera, this board remains extremely powerful and versatile for many other applications.โก
XIAO RP2040 with Arduino IDE
For this first test, I worked with the
Seeed Studio XIAO RP2040 and programmed it using Arduino IDE.
Before jumping into the code, I configured the software environment by following these steps:
Step 1. I downloaded and installed the latest version of
Arduino IDE according to my operating system.
Step 2. I launched the Arduino application.
Step 3. I added the Seeed Studio XIAO RP2040 board package to Arduino IDE:



Now, the Seeed Studio XIAO RP2040 is fully set up for Arduino IDE and ready for programming. ๐
๐Note: The setup process is pretty much the same for other microcontrollers too. Just make sure to check their installation guides and configuration details on their official pages.
XIAO RP2040 TESTING
To test the microcontroller, I decided to use an
OLED Display as the
output device.
I used the XIAO RP2040 to show a simple image on the screen. Since the OLED can only interpret data in hexadecimal format,
the image must first be converted before uploading it to the board.
๐Note:
Why Convert the Image to Hexadecimal?
OLED screens can't directly read image formats like JPG or PNG. Instead, they work with a sequence of numbers that define which pixels
should be turned on or off. These numbers are grouped into bytes, and their position in the matrix determines the image's orientation.
If the conversion is not done properly, the image might appear flipped, mirrored, or distorted on the display.
Tools like
image2cpp
help adjust it to ensure it displays correctly on the screen.
Image Preparation for OLED Display

Image Resizing Process

Getting the image code from image2cpp
๐Note: Visualize the complete code in Notepad++ or open the file in Notepad.
WOWKI - simulator
Before making the physical connections, I wanted to make sure my code worked properly. So, I tested it in the WOKWI online simulator.
๐Note: SDA (Serial Data) is the line used to transmit data between the devices, while SCL (Serial Clock) provides the clock signal that keeps communication synchronized. Both lines form part of the IยฒC communication protocol used by the OLED display.

ARDUINO IDE
After checking the simulation, I confirmed that both the code and the connections were correct. For the physical setup, I had to remember that on the XIAO RP2040, the IยฒC pins are SDA (D4) and SCL (D5). Once the wiring was done, I uploaded the same code from the Wokwi simulation to the board, and it worked perfectly.
๐Note: To download the complete code in the Arduino
IDE platform, click the button below.
Final Thought ๐ญ
This week's assignment allowed me to explore how hardware and software come together in a simple but complete workflow โ from image processing to electronic visualization. I learned how to convert an image into a readable format for an OLED display, test the code virtually using Wokwi, and then successfully transfer everything to the physical setup with the XIAO RP2040. Throughout this process, I realized how important it is to understand each step โ not just to make things work, but to know why they work. It was rewarding to see the final image appear on the display, knowing that it came from a mix of digital code logic, and physical wiring.
