Hobbies And Interests
Home  >> Hobbies >> Other Hobbies

How to Add Using a Microcontroller

A microcontroller is an integrated circuit (IC) that contains a processor, memory, and input and output channels. Robotics, computers, LED displays and many other electronic devices use microcontrollers to define and control how they function. For example, a microcontroller controls how a robot moves. The functions the microcontroller performs are defined in a user-generated program that is uploaded to the device. Many microcontroller projects require mathematical procedures to be executed, such as addition.

Things You'll Need

  • Microcontroller
  • Computer
Show More

Instructions

    • 1

      Connect your microcontroller to your computer. Launch your microcontroller's programming software.

    • 2

      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;

    • 3

      Type the code that begins serial communication between your computer and the microcontroller.

    • 4

      Type the code that adds the variables "num1" and "num2" and stores the sum in "total." Your code may resemble this:

      total = num1 + num2;

    • 5

      Add a line of code that prints the value stored in "total" to your screen.

    • 6

      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.


https://www.htfbw.com © Hobbies And Interests