This is an old revision of the document!
Just write the amplitudine and the phase and you will see the corresponding graph, also allowing you to zoom in or out.
Well, if you're trying to do a digital detox and want to feel like an old school 20th century math researcher, you have the perfect choice! Not only that, but with the graph options you can visualize concepts like interference, phase shift, and amplitude without the need for an expensive oscilloscope. Or, if you are an engineer working with signals all day it can be useful for quick visual verification of parameters before sending data to a (Digital-to-Analog Converter).
Phones are tempting, when you try do some quick math operations on them for some math exam you can get some Insta notifications or simply get a message and your focus can very easily be interrupted. It happened to me, it can happen to anyone. If you want to get rid of all digital devices when studying, you can use this calculator. The final purpose would be creating a full scientific calculator, yet that implies heavy optimization at the software level, due to the very limited RAM size of the microcontroller.
The system is coordinated by the ATmega328P microcontroller. The user inputs data using a 4×4 Keypad. The input software module detects key presses and transmits them to the Main Logic. It validates the input and calls the Display Driver to update the graphical interface on the TFT Screen via the SPI bus. Simultaneously, the logic triggers the Audio Generator to emit a confirmation sound through the passive Buzzer using a PWM signal. The variable voltage read from the Potentiometer is used to adjust the zoom of the displayed graph. Operations history is written bidirectionally to the SD Card Module.
This section outlines the physical implementation of the system, including the components used, their interconnection logic, and the communication protocols employed.
The following table lists all the hardware components used in the project:
| Component | Description/Role |
|---|---|
| ATmega328P Xplained Mini | Main MCU (Microcontroller Unit) based on the AVR architecture |
| 1.8” Color TFT LCD (ST7735) | High-resolution graphical output via SPI protocol |
| MicroSD Card Module | External storage for logs/data, sharing the SPI bus |
| 4×4 Matrix Keypad | Digital input for user commands and data entry |
| Slide Potentiometer (10kΩ) | Analog input for variable control |
| Passive Buzzer | Audio output device for acoustic feedback and alerts |
| Component | Pin Type | MCU Pin | Function |
|---|---|---|---|
| Keypad (Rows) | Digital | D2, D3, D4, D5 | Input scanning (Pull-up) |
| Keypad (Cols) | Digital | D6, D7, D8, D9 | Input scanning |
| Buzzer | PWM | D3 (shared) | Audio signal generation |
| TFT Screen (SCK) | SPI Clock | D13 | Shared SPI clock |
| TFT Screen (MOSI) | SPI Data | D11 | Master Out Slave In |
| TFT Screen (CS/DC/RST) | Control | D10, D9, D8 | Chip Select, Data/Cmd, Reset |
| SD Card (CS) | Control | D4 (shared) | Chip Select for SD Module |
| Potentiometer | Analog | A0 | 10-bit ADC conversion |
The system design follows a modular approach. The SPI Bus (Serial Peripheral Interface) is the backbone of the hardware, allowing the MCU to communicate with both the TFT Screen and the SD Card. To avoid bus contention, separate Chip Select (CS) lines are used.
The 4×4 Keypad is connected using a matrix scanning technique, utilizing 8 digital pins to minimize I/O usage. The Passive Buzzer is connected in series to the MCU to prevent overcurrent damage to the digital pin. The Slide Potentiometer acts as a voltage divider, providing a linear voltage between 0V and 5V to the ADC (Analog-to-Digital Converter) on pin A0.
The communication follows the SPI standard:
The audio output for the buzzer is generated using Timer-based PWM. By varying the frequency of the square wave, different musical notes are produced, while the duty cycle remains at 50% for optimal sound clarity.
This section describes the firmware architecture, the development tools, and the logic implemented to coordinate the hardware peripherals.
The project is developed using Visual Studio Code integrated with the PlatformIO IDE extension. This environment was chosen for its advanced features, such as:
To interface with the complex hardware modules, the following open-source libraries are utilized:
The firmware implementation relies on several key computational strategies:
The application logic is structured as a Finite State Machine. This allows the system to transition between different modes (e.g., MENU_NAVIGATION, DATA_ENTRY, PROCESSING, ERROR_STATE) without blocking the execution flow, ensuring the UI remains responsive.
Instead of using heavy interrupts for the keypad, a non-blocking polling algorithm is used within the main loop. This ensures that the system checks for user input while simultaneously updating the display or reading from the SD card.
Since the TFT screen and the SD card share the same SPI bus (MOSI, MISO, SCK), a manual Chip Select (CS) management algorithm is implemented. The firmware ensures that only one peripheral is active at any given time to prevent data corruption.
For logging data to the SD card, a circular buffer structure is planned to store temporary sensor readings before performing a bulk write operation, minimizing the performance impact of SD card latency.
The code is modularized into several key functional blocks:
The implementation of the project yielded a fully functional embedded system that successfully integrates all specified hardware and software modules. The core achievements include:
Overall, the project met its initial design specifications, operating smoothly via a standard 5V USB power supply and demonstrating excellent real-time reliability.
The development of this embedded system provided a comprehensive and practical experience in both hardware integration and low-level microcontroller programming. Successfully combining heterogeneous peripherals—such as a color display, external storage, and analog/digital inputs—on a resource-constrained platform like the ATmega328P demonstrated the importance of efficient system architecture.
Several key technical takeaways and challenges were identified during the project:
While the current breadboard prototype is fully functional, future iterations of the project could include:
TO BE CONTINUED Github Repo
ATmega328P Xplained Mini User Guide
Sitronix, ST7735 1.8" Color TFT Controller DatasheetATmega328P Datasheet
SD Association, Physical Layer Simplified Specification (SPI Mode Interface)