Assignments
Group Assignment
- Compare the toolchains and development workflows for available embedded architectures.
Individual Assignment
- Browse through the data sheet for your microcontroller.
- Write a program for a microcontroller, and simulate its operation.
GROUP ASSIGNMENT
Compare toolchains and development workflows

comparative microprocessors
We chose to compare the ESP32-C3 processor in XIAO ESP32-C3 from Seeedspeed and RP2040 from Raspberry Pi because they were microcontrollers we had in the laboratory.
XIAO ESP32-C3

ESP32-C3 family is an ultra-low-power MCU-based SoC solution that supports 2.4 GHz Wi-Fi and Bluetooth®Low Energy (Bluetooth LE). It has 25 pins for digital and analog outputs.
Raspberry Pi RP2040

RP2040 has a dual M0+ processor cores, DMA, internal memory and peripheral blocks connected via AHB/APB bus fabric. It has 11 pins for digital outputs and 4 for analog.
ESP32-C3 Data Sheet
Raspberry Pi RP2040 Data Sheet
INDIVIDUAL ASSIGNMENT
FIRST, what do you mean by Embedded Programming?
What is a microcontroller and a processor?
I did have experience once (5 years ago), programming a car with sensors. However I did it in a basic course with arduino where we just got to understand the programming codes.
What is Embedded Programming?

As always I had to make my own graphic to understand the steps. I got to understand embedded programming reffers to programming systems that are not computers but what its inside. And there are embedded systems to programm to make certain things. And it has components in which you have microcontrollers.
The microcontrollers work with a processor inside. I got to test the XIAO ESP32-C3. This is a development board made by Seeedstudio based in the ESP32-C3 microprocessor and works with Arduino with the language C++.
XIAO ESP32 -C3 d a t a s h e e t
To start the programming, we had to search the datasheet of the microcontroller we want to use, to understand how many ports and which are analog and digital. In this case the Seeedspeed Datasheet helped me to understand how many pins can connect to analog and digital. Uderstanding analog means variable results while digital 1 or 0.

Then I also shearched for the Seedstudio data sheet whereI culd understand easier what pin works for what.
Seedstudio XIAO ESP32-C3 Data Sheet

w r i t t i n g a program for the XIAO ESP32-C3
First, my instructors gave us an intro in programming while making a simulation in Wokwi.

Some important notes I took:
Then they gave us two boards to work with. One digital and one analog.
To first try and understand the programming.

Simulating and testing
TASK 1: Turn on the led and by 1 second turn off.

WOKWI Simulation
const int LED1 = D02 // PIN where is the LED
void setup() {
pinMode(LED1, OUTPUT);
}
void loop() {
digitalWrite(LED1, HIGH); // Turn on LED
delay(1000); // wait 1 second
digitalWrite(LED1, LOW); // Turn off LED
delay(1000); // wait 1 second
}
Task 1 video
TASK 2: Turn off the led by a button. (It was the opposite but i wanted to try)

WOKWI Simulation
const int LED1 = D0;
const int BOTON2 = D1;
void setup() {
pinMode(LED1, OUTPUT);
pinMode(BOTON2, INPUT);
}
void loop() {
int buttonState = digitalRead(BOTON2); // Read button state
if (buttonState == HIGH) { // if pressing the button
digitalWrite(LED1, LOW); // turns off LED
} else { // if not
(LED1, HIGH); // turns on LED
}
}
Task 2 video
TASK 3: Turn on and off by 1 second 3 leds.

WOKWI Simulation
Task 2 video
const int LED1 = D02 // PIN where is the LED
void setup() {
pinMode(LED1, OUTPUT);
}
void loop() {
digitalWrite(LED1, HIGH); // Turn on LED
delay(1000); // wait 1 second
digitalWrite(LED1, LOW); // Turn off LED
delay(1000); // wait 1 second
}
Task 1 video
const int LED1 = D0;
const int BOTON2 = D1;
void setup() {
pinMode(LED1, OUTPUT);
pinMode(BOTON2, INPUT);
}
void loop() {
int buttonState = digitalRead(BOTON2); // Read button state
if (buttonState == HIGH) { // if pressing the button
digitalWrite(LED1, LOW); // turns off LED
} else { // if not
(LED1, HIGH); // turns on LED
}
}
Task 2 video
const int LED1 = D0;
const int LED2 = D1;
const int LED3 = D2;
void setup() {
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
}
void loop() {
digitalWrite(LED1, HIGH); // turns on LED 1
delay(1000); // wait 1 sec
digitalWrite(LED1, LOW); // turns off LED 1
digitalWrite(LED2, HIGH); // turns on LED 2
delay(1000); // wait 1 sec
digitalWrite(LED2, LOW); // turns off LED 2
digitalWrite(LED3, HIGH); // turns on el LED 3
delay(1000); // wait 1 sec
digitalWrite(LED3, LOW); // Aturns off LED 3
}
TASK 4: Try the analog board with the light intensity.
Serial monitor showing the light intensity.
Feel free to play both videos at the
same time
(they were recorded at the same time).
const int sensorPin = A0;
void setup() {
Serial.begin(115200); // Initialize serial communication to see data on the serial monitor
}
void loop() {
int sensorValue = analogRead(sensorPin); // Read the analog value from the light sensor
float voltage = sensorValue * (3.3 / 4095.0); // Convert the analog value to voltage (range is 0 to 3.3V)
Serial.print("Sensor Value: ");
Serial.print(sensorValue);
Serial.print("\tVoltage