Skip to content

Week 04 - Embedded Programming

Group Assignment — Embedded Architectures Comparison

This week we compared different embedded platforms to understand their performance, workflow, and use cases.

The following systems were analyzed: - Arduino (ATmega) - ESP32 - STM32 - ATtiny - RP2040


Arduino (ATmega)

  • 8-bit microcontroller, ~16 MHz
  • Very simple development (Arduino IDE)
  • No built-in communication

✔ Easy to use
❌ Low performance

Use case: basic electronics and prototyping


ESP32

  • 32-bit, up to 240 MHz
  • Built-in WiFi + Bluetooth
  • Supports Arduino / ESP-IDF

✔ High performance + wireless
❌ More complex than Arduino

Use case: IoT, wireless devices


STM32

  • 32-bit ARM Cortex
  • High performance, real-time capable
  • Uses STM32Cube + advanced toolchain

✔ Industrial-level control
❌ Complex setup

Use case: robotics, embedded control systems


ATtiny

  • Small 8-bit microcontroller
  • Very low power
  • Limited pins and memory

✔ Cheap and compact
❌ Very limited features

Use case: simple standalone devices


RP2040

  • 32-bit dual-core (up to 133 MHz)
  • Developed by Raspberry Pi
  • Programmable in C/C++ or MicroPython

✔ Good performance, flexible
❌ No built-in wireless

Use case: embedded systems, custom boards


Comparison Table

Platform Type Performance Wireless Complexity Best Use
Arduino 8-bit MCU Low No Low Basics
ESP32 32-bit MCU High Yes Medium IoT
STM32 32-bit MCU Very High No High Industry
ATtiny 8-bit MCU Very Low No Low Minimal
RP2040 32-bit MCU Medium No Medium Custom boards

Conclusion

Each platform fits different needs:

  • Arduino → simple and beginner-friendly
  • ESP32 → best for wireless applications
  • STM32 → high-performance and precise control
  • ATtiny → minimal and low-power
  • RP2040 → flexible modern microcontroller

Microcontrollers Available in Lab

Our FabLab provides several microcontrollers that support both learning and prototyping:

  • Arduino Uno — widely used for teaching basic electronics
  • Arduino Nano / Micro — suitable for compact embedded designs
  • ESP32 — used for projects requiring Bluetooth or WiFi
  • ESP8266 — used for lightweight IoT applications

This variety allows selecting the appropriate platform depending on project complexity and communication requirements.

For my project, I selected ESP32 because of its built-in Bluetooth capability, which is required for wireless interaction.

Individual Assignment — ESP32 Bluetooth Gun Simulator

For the individual assignment, I decided to build a simple gun simulator based on ESP32.
The goal of this project was to use a microcontroller with wireless communication and create a device that can interact with a computer in a game-like environment.

I selected ESP32 because it has built-in Bluetooth, which makes it suitable for wireless input devices without requiring additional communication modules.

The idea of the project was to simulate a simple gun controller using physical buttons and motion-related interaction, then test its behavior in a first-person shooter environment.


Project Goal

The goal of this assignment was to:

  • program an embedded system using ESP32
  • use local input devices such as buttons
  • communicate wirelessly with a computer over Bluetooth
  • test the system in a practical scenario

In this project, the ESP32 acts as a wireless human interface device and sends user input to the computer.


Why I Chose ESP32

I chose the ESP32 mainly because of its integrated Bluetooth capability.
Compared to more basic boards such as Arduino Uno or ATtiny, ESP32 allows easier implementation of a wireless controller.

It also provides: - enough processing power for real-time input handling - multiple GPIO pins for buttons and sensors - support through Arduino IDE - a large amount of example code and libraries

This made it a practical platform for building an interactive prototype.


Browsing the Datasheet

As part of the assignment, I reviewed the ESP32 microcontroller documentation and focused on the features that were relevant for this project. The official assignment explicitly requires browsing and documenting information from a microcontroller datasheet.

The most relevant points for my project were:

  • Bluetooth support for wireless communication
  • GPIO pins for button input
  • 3.3V logic operation
  • enough processing capability for handling multiple inputs
  • USB programming support through the development board

For this project, the most important feature was the possibility to build a Bluetooth-based control device with a compact microcontroller board.


Project Concept

The physical idea of the project is a simple toy-gun-style controller.

The controller includes: - trigger button - second action button - optionally an additional button - ESP32 board as main controller - Bluetooth connection to a computer

The purpose was to test whether a custom handheld controller could send input to a PC and be used in a game environment.


Components Used

  • ESP32 development board
  • Push buttons
  • Jumper wires
  • USB cable for programming
  • Breadboard / temporary wiring setup

Optional future expansion: - IMU sensor for motion-based aiming - battery power supply - custom enclosure


Input and Communication Logic

This project combines two important parts of embedded programming:

Local input

The ESP32 reads the state of physical buttons connected to GPIO pins.

Remote communication

The ESP32 sends these button actions wirelessly to the computer through Bluetooth.

This matches the week requirement well, since the official brief asks for a microcontroller system that can both interact with local input/output and communicate through remote wired or wireless connections. :contentReference[oaicite:2]{index=2}


Development Workflow

I used the following workflow:

  1. Define project idea and required interaction
  2. Select ESP32 because of Bluetooth support
  3. Connect buttons to GPIO pins
  4. Program the board in Arduino IDE
  5. Upload and test code
  6. Pair the ESP32 with the computer over Bluetooth
  7. Test behavior in a game environment
  8. Improve response and interaction logic

This process helped me understand both the hardware and software sides of embedded programming.


Wiring

The basic wiring was simple:

  • one side of each button connected to GPIO pin
  • the other side connected to GND
  • internal pull-up resistors used in software

Example structure: - Button 1 → trigger input - Button 2 → secondary action - Button 3 → optional extra function


Programming Process

The ESP32 was programmed using Arduino IDE.

The main logic of the code was:

  • initialize Bluetooth functionality
  • define button pins
  • continuously read button states
  • detect button press events
  • send related Bluetooth keyboard or mouse action to the computer

An important part of the project was avoiding repeated uncontrolled input.
For this reason, the button logic was improved so that one button press produces one action instead of continuous looping.

This made the controller behavior more stable and easier to test.


First Test Version

The first version of the project focused only on button-based wireless interaction.

At this stage, the objective was not to create a complete final controller, but to verify that:

  • ESP32 connects correctly over Bluetooth
  • button presses are detected reliably
  • the computer receives the commands
  • the system can be tested in a practical scenario

This first step was important before adding more advanced functions.


Testing in Game Environment

After uploading the code and pairing the board, I tested the controller in a shooter-style game environment.

The purpose of this test was to see whether the ESP32-based controller could be used as a practical wireless input device.

During testing, I checked:

  • Bluetooth connection stability
  • button response
  • delay between physical action and game response
  • usability in a real application


Challenges

During development, several challenges appeared:

  • Bluetooth library compatibility
  • compile errors with external libraries
  • repeated button input behavior
  • tuning the controller response for practical use

These issues were useful for learning, because they showed that embedded programming is not only about writing code, but also about debugging libraries, communication, and behavior.


What Worked

The successful parts of the project were:

  • ESP32 was a good choice for wireless communication
  • button input reading was simple and reliable
  • Bluetooth interaction made the prototype more practical
  • the project created a clear connection between embedded programming and real application testing

What Can Be Improved

The current version is a basic prototype, but it can be improved further.

Possible next steps: - add IMU sensor for motion control - improve ergonomics with custom enclosure - optimize latency and smoothing - combine buttons and motion in one controller - build a more game-oriented final version


Hero Shot

Final prototype of the ESP32-based gun simulator:


Source Code

The source code for this assignment is included below and/or attached as a separate file, as required by the weekly documentation guidelines. The official FAQ notes that screenshots alone are not enough; source code should be included as text or downloadable files. :contentReference[oaicite:3]{index=3}

```cpp // Paste your final code here