Arduino Mega – Making a Calculator (Serial Port)

In this tutorial I am going to show you how to make a calculator using Arduino Mega 2560 but you can use any Arduino Board. This calculator use only UART module, to communicate with computer. You don´t need any extra parts.

Considerations

After opening the serial monitor, you should ensure that the 9600 and “newline” are selected, in the options in the bottom bar, as you can see in image below:

Code

As you can see in the code below, there is a function called “serialEvent ()”, this function is recognized by the native libraries of Arduino and therefore the name of this function can not be changed, otherwise it will not be recognized and the system will not work.

Copy the code bellow to your Arduino IDE project and save it. Then open serial monitor of IDE or any other and insert the numbers and operator.

João Louro

Author: João Louro

Electrical Engineer with special interest in Embedded Systems, Real Time Operating Systems and Audio. With a degree in Electrical and Computer Engineering in the field of Electronics and Computers and currently studying Master's degree in Electrical Engineering.

Leave a Reply

Your email address will not be published. Required fields are marked *