= (Basic assignment)

From Microduino Wiki
Jump to: navigation, search
  • = assignment operator(single equal sign)

Assignment operator(single equal sign)

Assign the numerical value on the right of the equal sing to the variable on the left of it.

In C, single equal sign is called as assignment operator whose meaning is different from mathematical one. It tells the microcontroller to store the numerical value or the result of the calculation expression on the right of the equal sign in the variable on the left of the equal sign.

  • Example:

  int sensVal;  //claim a integer variable called sensVal
  senVal = analogRead(0);  //store the input voltage of analog pin 0 in variable SensVal
  • Note:

Make sure that the variable on the left of the assignment operator can save the numerical value on the right. If it isn’t large enough to save the value, the value saved in the variable will be mistaken.

Don’t mix up the assignment operator [=](single equal sign)and comparison operator[==](double equal signs), which means the two expressions are equal.


[Return to Arduino Syntax Manual]