Rust Calculator
A calculator that take numbers and opperations as inputs and outputs results to a i2c screen
Author: Scrob Sebastian-Mina
GitHub Project Link: https://github.com/UPB-PMRust-Students/project-Seby-S/tree/main
Descriptionβ
This project implements a calculator using a Raspberry Pi Pico 2w microcontroller running rust code. It supports:
- Basic arithmetic: addition, subtraction, multiplication, division
- More advanced functions: exponentiation, square roots, and trigonometric operations
- Graphical interface: an OLED display that shows your input and results
- Audible feedback: buzzer beeps confirm key presses
Input comes from 2 seperate keypads:
-a 4x3 matrix keypad used to enter numbers(0-9 keys), a '=' button and a button that retanins the previously calculated answer for ease of us;
-a 4x4 matrix keypad used to enter the signs and operations possible. The keys are for: +,-,*,/,^,radical,sin,cos,tan,cotan,log(base10),!. There is also a backspace button that if held pressed for 1 second it clears the screen, parentheses buttons and a button for decimal points(.);
Output is displayed via the I2C Oled sceen.
Motivationβ
I wanted to make something practical for my project and I use calculators all the time in my life. Since I have a calculator it is easy to test and compare how my project should behave. I also like simple user input/output devices.
Architectureβ
Componentsβ
- Raspberry Pi Pico 2w: connected to everything and runs code
- Keypad(4x4): connect with 8 GPIO pins
- Keypad(4x3): also connect with 7 GPIO pins
- OLED display: connect with GPIO pins and uses I2C (4 pins)
- Buzzer: connect with GPIO pins (2 pins)
Logβ
Week 5 - 11 Mayβ
Parts have arived and got the bords to work.
Week 12 - 18 Mayβ
Schematics and wiring done. Now coding for the dispaly and keypad is in progress.
Week 19 - 25 Mayβ
Finishing the coding part.
Hardwareβ
- Raspberry Pi Pico 2W (RP2350): Main microcontroller handling system logic and display
- OLED Display 0.96'' I2C: display for UI and results
- Keypad(4x3): user input for numbers,clear key and '=' key;
- Keypad(4x4): user input for operations,backspace,decimal poin, and paranthesis
- 3V active buzzers: audio feedback for key presses
- Breadboard & wires for prototyping
Schematicsβ
Bill of Materialsβ
| Device | Usage | Price |
|---|---|---|
| Raspberry Pi Pico 2W | The microcontroller | 39 RON |
| Raspberry Pi Pico 2W | The debug probe | 39 RON |
| Display OLED 0.96'' I2C alb | output | 16 RON |
| Tastatura matriceala 4x4 | input | 7 RON |
| Tastatura numerica 4x3 | input | 18 RON |
| 2x Buzzer Activ de 3 V | audio feedback | 2 RON |
| Breadboard HQ (830) | platform | 10 RON |
| Set Fire Tata-Tata | wires | 8 RON |
| Fire Colorate MamΔ-TatΔ | wires | 10 RON |
| Total: 149 RON |
Softwareβ
| Library | Description | Usage |
|---|---|---|
| embassy-rp | Peripheral access & async drivers for the RP2040 | Used for GPIO, I2C, timers, and initializing peripherals |
| embedded-graphics | 2D graphics primitives | Used for text and symbols for the OLED screen |
| embassy-executor | Async task executor for Embassy | Runs the async tasks |
| ssd1306 | OLED display driver crate | Provides I2C interface for the OLED display |
| libm | Math library for no-std environments | Provides math functions (sin, cos, tan, log, ^, etc.) |
| heapless | Fixed-capacity, no-std collections | Used for storing the input expression string without heap allocation |
| defmt | Lightweight logging framework for embedded | Debug/info/error logging |
| panic-probe | Panic handler with defmt integration | Reports panic messages |