Assignments

Week 4 – Embedded Programming

Assignment

Individual assignment

  • Browse through the data sheet for a microcontroller.
  • Write and test a program for an embedded system using a microcontroller to interact (with input and/or output devices) and communicate (with wired or wireless connections).
  • Extra credit: assemble the system
  • Extra credit: try different languages and/or development environments

Group assignment

  • Demonstrate and compare the toolchains and development workflows for available embedded architectures.

Contribution to the Group Assignment

During the group assignment, my contribution focused on the technical research and structured comparison of different microcontroller boards.

🔗 If you want to explore the Group Assignment in more detail, you can visit the official Fab Academy page:

Visit Fab Academy ULima →

I reviewed the official datasheets of the following boards:

  • Arduino R3
  • ESP32
  • Raspberry Pi Pico 2W
  • Arduino Nano

From each datasheet, I extracted and analyzed key technical specifications such as processor architecture (8-bit vs 32-bit), clock frequency, Flash memory, SRAM, operating voltage, number of digital and analog I/O pins, communication protocols (UART, SPI, I2C), and wireless connectivity features.

Additionally, I developed a comparative table that organized these technical parameters in a clear and structured format. The comparison criteria were selected based on embedded system requirements, including processing capability, memory constraints, communication needs, and hardware flexibility.


Development Board and Microcontroller

What is a Development Board?

A development board is a complete electronic platform designed to help us prototype, test, and program embedded systems easily. It includes a microcontroller as its main brain, along with additional components such as voltage regulators, USB interface, communication ports, buttons, LEDs, and sometimes wireless modules.

In simple words, the development board is the physical platform that allows us to interact with the microcontroller safely and efficiently without building the entire circuit from scratch.

Development board

What is a Microcontroller?

A microcontroller is a small integrated circuit that acts as the brain of an embedded system. It contains a processor (CPU), memory, input/output pins, and communication interfaces all inside a single chip. It executes programs written by the user to control sensors, motors, LEDs, displays, and communication systems.

Every development board includes at least one microcontroller. The board provides the supporting electronics, while the microcontroller performs the actual computation and control tasks.

Microcontroller

Click the button

Group Assignment Reflection

During the group assignment, I learned that reading a microcontroller datasheet is essential to understand the real capabilities and limitations of each board. I understood how factors such as architecture, clock frequency, memory, voltage logic, and communication protocols influence board selection for different embedded applications. This process also helped me distinguish between a development board and the microcontroller it contains, and improved my ability to compare platforms using technical information in a more objective and engineering-based way.

Development Boards Comparison

Board comparison
Feature UNO R3 Nano UNO R4 WiFi ESP32 Pico 2 W
Main MCU ATmega328P ATmega328P R7FA4M1 (ARM M4) Xtensa LX6 RP2350
Architecture 8-bit AVR 8-bit AVR 32-bit ARM Cortex-M4 32-bit Xtensa (dual-core) 32-bit ARM Cortex-M33 (dual-core)
Clock Speed 16 MHz 16 MHz 48 MHz Up to 240 MHz Up to 150 MHz
Flash Memory 32 kB 32 kB 256 kB External (~4 MB) External (~4 MB)
SRAM 2 kB 2 kB 32 kB 520 kB Up to 520 kB
WiFi No No Yes Yes Yes
Bluetooth No No BLE BLE BLE

Individual assignment

In this individual assignment, I will test and compare two different microcontroller boards: the Seeeduino and the Arduino R4. The objective is to evaluate their behavior, compatibility, and performance for my embedded systems development.

Before working with the physical boards, I will first use a simulation environment. This allows me to validate the circuit design, test the code, and detect possible errors in a safe and controlled way. Using a simulator reduces the risk of damaging components and helps optimize the development process.



1) Embedded Systems

An embedded system is a specialized computing system designed to perform a specific task within a larger device or process. Unlike general-purpose computers, embedded systems are built for dedicated functions such as sensing, control, automation, and real-time interaction. They are commonly found in robots, industrial equipment, smart devices, and manufacturing systems.


Basic Composition: Input → Controller → Output

In general, an embedded system can be described using three main blocks:

  • Input: Sensors or user inputs that provide data to the system (e.g., button, LDR, potentiometer, temperature sensor).
  • Controller: The microcontroller that reads inputs, processes information, and makes decisions (e.g., Seeeduino, Arduino UNO R4).
  • Output: Actuators or indicators controlled by the system (e.g., LED, buzzer, motor, LED matrix).

Input

Input example
Figure: Input example (sensor or button).

Controller

Microcontrollers used
Figure: Microcontrollers used (Seeeduino and Arduino UNO R4).

Output

Output example
Figure: Output example (LED or LED matrix).

2) System Architecture

The embedded workflow follows a standard architecture where the controller reads an input signal, processes it, and produces an output action. In addition, the system can communicate the measured values and states to a computer or another device using a wired or wireless connection.

System architecture diagram

Workflow

  1. Read input: Acquire data from a sensor or button (analog/digital).
  2. Process data: Filter, average, debounce, or compare against a threshold.
  3. Decision: Determine the system state (e.g., ON/OFF, alert/not alert).
  4. Drive output: Activate an actuator (LED, buzzer, motor, LED matrix).
  5. Communicate: Send values and system state through Serial (wired) or WiFi/BLE (wireless, if available).

3) Safety First: Simulation Before Hardware (Tinkercad)

Before building the circuit physically, I will first test the logic and wiring using a simulator (Tinkercad). Simulating the circuit helps validate connections and program behavior in a controlled environment, reducing the risk of short circuits, incorrect pin usage, or damaging the board and components. Once the simulation results match the expected behavior, I will implement the same circuit on real hardware and perform final tests.

Exercise 2.1

In the simulation, the onboard LED responded immediately after uploading the code, confirming that the digital output pin was correctly configured. The LED turned on and off at the programmed interval without delays or unstable behavior, validating the basic output.

Exercise 2.1

Exercise 2.2

During the simulation, the external LED connected through the breadboard behaved as expected when the digital signal was activated. The resistor correctly limited the current, and no abnormal behavior was observed. The simulation allowed verification of wiring connections and polarity before assembling the real circuit.

Exercise 2.2

4) Exercises

I prepared three small exercises to demonstrate embedded interaction and communication-ready structure: (1) Seeeduino blinking an LED, (2) Arduino UNO R4 blinking an LED, and (3) Arduino UNO R4 controlling the built-in LED matrix. Each code block is included as plain text so anyone can copy and paste it directly from the repository.


Exercise 1 — Seeed Studio: BLINK LED

This program turns an LED on and off repeatedly. It can use the onboard LED (LED_BUILTIN) or an external LED connected to a digital pin.

// Exercise 1: Seeed Studio - Blink LED
const int LED_PIN = LED_BUILTIN; // or set a pin number, e.g., 6

void setup() {
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(500);
  digitalWrite(LED_PIN, LOW);
  delay(500);
}

This code configures a digital pin as an output and repeatedly turns the LED on and off. It demonstrates basic digital control and timing using delays.

Seeed board demo

Exercise 2 — Arduino UNO R4: BLINK LED

Same idea as Exercise 1, but tested on Arduino UNO R4.

// Exercise 2: Arduino UNO R4 - Blink LED
const int LED_PIN = LED_BUILTIN;

void setup() {
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(300);
  digitalWrite(LED_PIN, LOW);
  delay(300);
}

This code verifies correct digital output behavior on the Arduino UNO R4 and confirms proper pin configuration.

UNO R4 blink

For the physical implementation, I will use an external LED mounted on a prototyping board (breadboard). The LED will be connected to a digital output pin through a current-limiting resistor (110Ω–220Ω) to prevent damage. This setup allows me to clearly visualize the output behavior of the Arduino UNO R4 during testing.

// Exercise 2: Arduino UNO R4 - External LED on pin 6
const int LED_PIN = 6;

void setup() {
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(300);
  digitalWrite(LED_PIN, LOW);
  delay(300);
}

This program controls an external LED and validates real hardware connections using a current-limiting resistor.

External LED wiring

I added a push button connected to pin 2 to allow user interaction.

// Arduino UNO R4 - LED controlled by Button on pin 2
const int buttonPin = 2;
const int ledPin = 6;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  int buttonState = digitalRead(buttonPin);

  if (buttonState == LOW) {
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(ledPin, LOW);
  }
}

This code reads a digital input from a button and controls an LED, demonstrating real-time interaction.

Button wiring

Exercise 3 — Arduino UNO R4 WiFi: Built-in LED Matrix

This exercise displays a simple pattern on the built-in LED matrix.

#include <Arduino_LED_Matrix.h>

ArduinoLEDMatrix matrix;
uint8_t frame[8][12] = {0};

void setup() {
  matrix.begin();
  frame[0][0] = 1;
  matrix.loadPixels(frame);
}

void loop() {}

This code initializes the LED matrix and displays a simple pixel, demonstrating control of more complex output devices.



5) Technical Comparison: Seeed Studio XIAO nRF52840 vs Arduino UNO R4

Both controllers can run embedded applications (read inputs, process data, drive outputs, and communicate), but they differ in processing, memory, logic voltage, and onboard features. Since my Seeeduino is the Seeed Studio XIAO nRF52840, the specs below refer to this exact model.

VS
Feature Seeed Studio XIAO nRF52840 Arduino UNO R4 (Minima / WiFi)
Microcontroller Nordic nRF52840 (Arm Cortex-M4F) Renesas RA4M1 (Arm Cortex-M4)
Clock speed Up to 64 MHz 48 MHz
Memory (Flash / RAM) 1 MB Flash / 256 KB RAM + (board) 2 MB QSPI Flash 256 KB Flash / 32 KB RAM
Logic / Operating voltage 3.3 V logic (careful with 5 V sensors/modules) 5 V operating voltage (UNO-style compatibility)
Wireless connectivity Bluetooth LE (BLE) + NFC Minima: no wireless
WiFi: includes ESP32-S3 module (WiFi/BLE)
Communication interfaces I2C, UART, SPI (varies by board variant) UART, I2C, SPI, CAN + DAC
Onboard special features Very compact form factor; some variants include IMU + mic (Sense) UNO R4 WiFi includes built-in 12x8 LED matrix
(Minima does not include the matrix)
Best fit (summary) Compact BLE/NFC projects, low-power wearables, TinyML/IoT BLE applications Classic Arduino ecosystem compatibility, education, 5V modules, matrix demos (WiFi)