Things You'll Need
Instructions
Connect your microcontroller to your computer. Launch your microcontroller's programming software.
Declare the following integer variables: "num1," "num2" and "total." "Num1" and "num2" are the integers that are being added to one another. "Total" is the final sum. Assign values to "num1" and "num2." Your code may resemble this:
int num1 = 4;
int num2 = 7;
int total;
Type the code that begins serial communication between your computer and the microcontroller.
Type the code that adds the variables "num1" and "num2" and stores the sum in "total." Your code may resemble this:
total = num1 + num2;
Add a line of code that prints the value stored in "total" to your screen.
Test the code, if your programming application provides a test function. Upload the code to your microcontroller. Run the program. The sum appears on your screen.