Skip to content

week 4. Embedded Programming

Group Assignment

This week I worked on embedded programming. I learned how to program a microcontroller and test basic functionality.

https://fabacademy.org/2026/labs/dilijan/assignments/week04/

Tools

  • Arduino IDE
  • Seeed Studio XIAO RP2040
  • USB cable
  • Computer

Individual Assignment

During the group work, we explored different microcontrollers and their capabilities. I chose the Seeed Studio XIAO RP2040 because of its compact size and compatibility with Arduino IDE.

I selected the XIAO RP2040 because it is small, easy to use, and suitable for future project integration.

  1. Downloaded and installed Arduino IDE.
  2. Opened the Seeed Studio website.
  3. Copied the board manager URL.

  1. Added the URL into Arduino IDE preferences.
  2. Installed the XIAO RP2040 board package.

  • Connected the XIAO RP2040 to the computer.
  • Selected the correct board from the menu.
  • Selected the COM port.

Before making connections, I reviewed the RP2040 pinout diagram to better understand the pin functions and avoid incorrect wiring.

Programming

After studying the RP2040 pinout, I created a simple program to test input reading from pin D0.

The code initializes serial communication and sets pin D0 as an input.
The program continuously reads the digital state of the pin and prints “CLOSED” or “OPEN” in the Serial Monitor depending on the input signal.

  • Serial.begin(9600) initializes serial communication
  • pinMode(D0, INPUT) sets pin D0 as input
  • digitalRead(D0) reads the pin state
  • Serial.println outputs the result

Code

void setup() {
  pinMode(D0, INPUT);
  Serial.begin(9600);
}

void loop() {
  if (digitalRead(D0) == HIGH) {
    Serial.println("CLOSED");
  } else {
    Serial.println("OPEN");
  }
}

Code Screenshot

Arduino Code


Serial Output

OPEN
CLOSED
OPEN

Serial Monitor


This test helped me understand how to read digital input signals and verify hardware connections.


Functions and Variables (Additional Learning)

During this week, I also explored basic programming concepts such as functions and variables in Arduino.

Example Code

#define pin1 17

int distSens = 17;
float var2 = 17.444;
String var3 = "hello Gyumri";
bool var4 = true;

const int var5 = 68;

void myFunc() {
  digitalWrite(pin1, HIGH);
  delay(500);
  digitalWrite(pin1, LOW);
  delay(500);
}

void setup() {
  pinMode(pin1, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  myFunc();
}

📷 Code Example Image

Arduino Code Example


Key Concepts

  • Function → reusable block of code
  • Variables → store data
  • setup() → runs once
  • loop() → runs continuously

Common Mistakes

#defint pin1 14      // incorrect
char var3 = "text";  // incorrect
bool var4 = tru;     // incorrect

Correct version:

#define pin1 14
String var3 = "text";
bool var4 = true;