In week 4, we focused on embedded programming. We worked with microcontrollers and learned how to write code that interacts with hardware components. We also learned how to solder electronic components and understand GPIO (General Purpose Input/Output) pins.
1. Group Assignment
This week, we completed our second group assignment.
You can see the group assignment at the following link: Group Assignment
2. Individual Assignment
For the embedded programming assignment, I worked with two microcontrollers: Arduino Uno and Seeed ESP32.
First, I made a Dino Run game on the Arduino Uno to focus on the physical connections and understand them better.
Here are the components that I used:
I followed the instructions in the tutorial to build and test the Dino Run game. Here is the tutorial link: Dino Run Game Tutorial
Before uploading the code, don't forget to check the microcontroller port number in the device monitor under the port section, then select the correct port type.
💡 Note: Put the header file in the same folder as the .ino file and change the include path
#include <LiquidCrystal_I2C.h> to #include "LiquidCrystal_I2C.h". Alternatively, you can keep it as is, but place the header file inside the Arduino IDE lib directory.
Then I tried to connect the Arduino Uno to the serial monitor by editing the Dino game code. Since I wanted to show the output in color, I had to download PuTTY.
💡 Note: Make sure to set the correct COM port in the Arduino IDE and the correct baud rate in PuTTY.
💡 Note: When you open PuTTY, make sure to close any other terminal or serial monitor that may be running to avoid connection conflicts on the same port.
After I understood the hardware part, I decided it was time to write my own code.
I chose to write code for a Reaction Time Test using the Arduino Uno microcontroller. The code measures the time it takes for a user to react to a visual stimulus (an LED turning on) and displays the reaction time on the serial monitor and LCD.
Code flow:
1. Initialization Phase (Setup)
The system configures all hardware pins, starts Serial communication, and initializes the LCD.
It reads the saved best reaction time from EEPROM and resets it if the value is invalid.
Finally, it waits for the user to press the button before starting the game.
2. Ready & Countdown
The LCD displays “READY…”, and LEDs light up sequentially with buzzer sounds.
This creates a visual and audio countdown to prepare the player.
3. Random Delay (Fairness Step)
After the countdown, the program waits for a random time between 1–4 seconds.
This prevents the player from predicting when the signal will appear.
4. GO Signal & Start Timing
All LEDs turn on and a buzzer tone plays to indicate the start of the reaction test.
At that exact moment, the program records the start time using millis().
5. Reaction Measurement & Record Check
When the button is pressed, the system records the end time and calculates the reaction speed.
It compares the result with the stored best time and updates EEPROM if a new record is achieved.
6. Display Results & Reset
The LCD shows the current reaction time along with the best recorded time.
After a short delay, the LEDs turn off and the system waits to begin a new round.
For this assignment, I learned how to solder electronic components. Our instructor gave us a short session on how to solder electronics. Here is a helpful reference: Soldering Guide
I soldered the ESP32-C3 board using a soldering iron and solder wire. I made sure to connect all the pins correctly and securely.
Before Soldering
After Soldering
B. Understanding GPIO
I first tried to run my code on the ESP32 board using the pin numbering shown on the board in the image below.
It didn’t work at first. After some research, I found the correct GPIO pins and tried them, and they worked perfectly.
Here is my conversation with ChatGPT, which helped me fully understand the GPIO mapping: View the full conversation.