Code Basics -Arduino C The Arduino uses a slightly reduced C/C++ programming language. In this recipe, we will remember a few basics of C/C++. Ensure that you have Arduino IDE Installed on your Laptop/PC. Here is a simple example of basic Arduino C/C++ manipulating two variables: // Global Variables int var1 = 10; int var2 = 20; void setup() { // Only execute once when the Arduino boots var2 = 5; // var2 becomes 5 once the Arduino boots } void loop(){ // Code executes top-down and repeats continuously if (var1 > var2) { // If var1 is greater than var2 var2++; // Increment var2 by 1 } else { // If var1 is NOT greater than var2 var2 = 0; // var2 becomes 0 } } When we upload a sketch to the board, the Arduino software first compiles the code. If there is an error in the code, it will write it in the Status D...
Electronics Projects based on Arduino Boards, 8051 Micro-controller, Modules, Sensors and much more on Electronixity.