Week 4 Embedded programming

It was a challenging week for me and I gained some embedded programming experience. Includes simple programming language, microcontroller features, etc. When the control program is running, it's really interesting.

Learning Objectives

Group assignment:

I have practiced embedded programming using Arduino Uno, micro:bit v2, and XIAO ESP32C3.

1. Tech specs

1.1 Comparison Between Arduino Uno, micro:bit v2, and XIAO ESP32C3

Feature Arduino Uno micro:bit v2 XIAO ESP32C3
Microcontroller ATmega328P nRF52833 ESP32-C3 (32-bit RISC-V)
Memory Flash: 32 KB, SRAM: 2 KB, EEPROM: 1 KB Flash: 512 KB, RAM: 128 KB Flash: 4 MB, SRAM: 400 KB
GPIO Pins 14 digital pins (6 support PWM), 6 analog input pins 25 programmable GPIO pins (including 3 analog inputs) 11 GPIO (6 PWM, 4 ADC, 1 DAC)
Communication Interfaces UART, SPI, I2C BLE, NFC, USB, SPI, I2C Wi-Fi, BLE, UART, SPI, I2C
Power Supply USB or External Power (7-12V) USB or Battery Pack (2xAAA Batteries) USB-C (5V), Li-Po Battery (3.7V)
Dimensions Approx. 68.6 mm x 53.4 mm Approx. 52 mm x 43 mm 21 mm x 17.5 mm
Programming Environment Arduino IDE (Primarily C/C++) MakeCode, MicroPython Arduino IDE, PlatformIO (C/C++)
Arduino Uno micro:bit v2 XIAO ESP32C3

1.2 Arduino Uno

The Arduino UNO is the best board to get started with electronics and coding. Datasheet

1.2.1 Board topology

1 1

1.2.2 Schematic diagram

1 1

1.2.3 Connector Pinouts

1

đŸ› ī¸1.2.4Install Arduino IDE on Windows

✅ Visit the Official Website Website

💾 Download for Windows,Click on Windows Installer (for Windows)

đŸ’ģ Install the Arduino IDE

  1. Double-click the downloaded .exe file
  2. Accept the license agreement
  3. Select all components (default options are fine)
  4. Choose an installation location (or keep default)
  5. Click Install and wait for it to finish
  6. Click Finish to launch the Arduino IDE

1.2.5 Upload and Run Arduino Program

Step-by-Step Guide:

  1. 🔌 Connect the Arduino Board: Use a USB cable to connect the Arduino to computer.
  2. đŸ–Ĩ Open Arduino IDEArduino official website.
  3. âš™ī¸ Select Board & Port:
    • Go to Tools → Board and select your Arduino Uno.
    • Go to Tools → Port and select the correct port COM5.
  4. 📋 Code: Open the code.
  5. ✅ Compile & Upload Code:
    • Click the âœ”ī¸ (checkmark icon) to verify the code.
    • Click the âŦ†ī¸ (upload icon) to upload the code.
  6. 📟 Open Serial Monitor:
    • Go to Tools → Serial Monitor .(shift+alt+M)
    • Set baud rate to 9600.
    • Check code

1.3 micro:bit v2

The micro:bit is a tiny programmable computer designed by the BBC for education. Datasheet

1

1.3.1 Connector Pinouts

1 1 1 1

1.3.2 How to Run a Program on micro:bit

đŸ› ī¸ What You Need:

🧩 Method A: Using MakeCode (Block-Based Programming)

  1. Go to https://makecode.microbit.org
  2. Click "New Project" to start coding with blocks
  3. Click "Download" to get the .hex file
  4. Connect your micro:bit to your computer via USB
  5. Drag and drop the .hex file to the micro:bit drive
  6. The program will upload and start running automatically

🧑‍đŸ’ģ Method B: Using Python (MicroPython)

  1. Go to https://python.microbit.org
  2. Write your Python code, for example:
from microbit import * while True: display.scroll("Hello!") sleep(1000)
  1. Click "Download" to get the .hex file
  2. Connect your micro:bit and drag the file into the drive

📌 Tips:

1.4 XIAO ESP32C3

The Seeed Studio XIAO ESP32C3 is a tiny and powerful development board with Wi-Fi and BLE capabilities, based on the ESP32-C3 RISC-V processor. Datasheet

1.4.1 Schematic Diagram

xiao_schematic xiao_schematic2

1.4.2 Connector Pinouts

xiao_pinout

đŸ› ī¸ 1.4.3 Install Arduino IDE and Setup for XIAO ESP32C3

✅ Visit the Official Arduino Website Arduino IDE

💾 Install Board Manager URL: Open Preferences and add this URL:

https://espressif.github.io/arduino-esp32/package_esp32_index.json xiao_schematic2

🔧 Board Manager: Go to Tools → Board → Boards Manager, search for ESP32 and install it.

💡 Select Board: Go to Tools → Board and select Seeed XIAO ESP32C3.

xiao_schematic2 xiao_schematic2

1.4.4 Upload and Run Program

Step-by-Step Guide:

  1. 🔌 Connect XIAO ESP32C3: Use a USB-C cable to connect it to your computer.
  2. đŸ–Ĩ Open Arduino IDE
  3. âš™ī¸ Board & Port:
    • Tools → Board → Seeed XIAO ESP32C3
    • Tools → Port → COMxx
  4. 📋 Write or Open Code
  5. ✅ Compile & Upload:
    • Click the âœ”ī¸ icon to verify
    • Click the âŦ†ī¸ icon to upload
  6. 📟 Open Serial Monitor:
    • Tools → Serial Monitor (Shift + Alt + M)
    • Set baud rate to 115200

📌 Tips:

✅ Summary

đŸŸĻ Arduino Uno

Arduino Uno is ideal for more advanced users who want flexibility and hardware control. Great for robotics, sensors, and real-world device building.

🟩 micro:bit

micro:bit is perfect for beginners and education. It has built-in features that make learning fast and fun, especially in classrooms.

🟧 XIAO ESP32C3

XIAO ESP32C3 is compact yet powerful, making it excellent for IoT projects, wearable tech, and wireless applications. With built-in Wi-Fi, BLE, and support for modern development tools, it bridges the gap between beginner boards and professional solutions.

Individual assignment:

2.1 Dual-color light

Using an Arduino UNO board to design a red-green dual-color LED system

2.1.1 Code

1 1 1

2.1.2 Running & Testing

1 1

2.2 RGB light with seven colors

Using a micro:bit to create a seven-color LED system

2.2.1 Code

1

2.2.2 Running & Testing

1 1 1 1 1

2.3 Smiley face and heart button lights

Using a micro:bit to create smiley face and heart button lights>

2.3.1 Code

1

2.3.2 Running & Testing

1 1

2.4 Timer

Using a micro:bit to build a timer

2.4.1 Code

1

2.4.2 Running & Testing

2.5 Rainbow LED blinking

Using the Seeed Studio XIAO ESP32-C3 to control a multi-color LED

2.5.1 Code

1

2.5.2 Running & Testing

CODE

Code2.1 for this week Code2.2 for this week Code2.3 for this week Code2.4 for this week Code2.5 for this week