For ECE 271, the sophomore Digital Logic design course at OSU, the entire class was contracted to supply mini 2-week projects for the yearly OSU Engineering Expo, ideally something that shows off digital logic or digital logic/hardware concepts. For my contribution, I created a small AVR based minimalist calculator, using only two SPDT switches and a single pushbutton.
This project uses the idea of a shift register for the two operand inputs. Operands are entered one bit at a time using the two SPDT switches, entering a 1 or 0 into the least significant bit of the operand. The pushbutton acts as a “clock” signal for, essentially, these two shift registers, leading to a logical left shift of the two GPRs containing the operands once the clock button is pushed.:w
Essentially a miniature state machine, the program keeps track of how many times the clock pushbutton has been pressed. Once it has been pressed 8 times for each of the bits of the operands, the two switches are used to form a 2-bit number, allowing for 2^2 (4) possible operations to be performed. These are displayed on the Nokia 5110 LCD, for either add/subtract/multiply/dividing of the two operands.
Once the pushbutton has been pressed after displaying the result of the operation, the state machine moves back to the initial state, allowing another computation to be performed.
Due to a lack of time to prepare for the expo, the power supply was provided by a YYFRobot USB/DC In module. The display is a Nokia 5110 LCD. The entire project was soldered on a tiny protoboard over the course of a night or two. All in all the project consists of:
- (1) ATmega328P
- (1) Pushbutton
- (2) SPDT toggle switches
- (1) Nokia 5110 LCD
- Many wires
Any 5V power supply can be plugged into one of four sets of power pins on the back of the board. In the above pictures, a 4.5V battery pack formed of 3 AA batteries was used, for calculation on the go.
The final board design, with an 8 pin header for the Nokia 5110 LCD. Additionally, the reset pin on the AVR has a 1 pin header attached to it for easy programming on the board, as several of the Nokia control pins are on the SPI bus for the ATmega328 :)
Lastly, I’d like to thank LittleBuster and SkewPL on GitHub for making this possible. I used their open source code for controlling the Nokia 5110 display, which made development much quicker and painless. You can find their projects here and here.
The source code for the main program of this project can be found here.