Almost every application which we use today needs a microcontroller. And to make a perfectly working application we need to program a microcontroller properly so that it works perfectly as we need it to work.
One such microcontroller platformthat is widely used and which is fully open sourced is the arduino.
![]() |
ARDUINO UNO |
So in this post and following posts we are going to learn about programming in arduino.
Lets first start with the basics.
There are two main functions which is a must in arduino coding. These two functions mst be included in every code. -
- void setup() - As the name suggests, this loop is a setup for functions -
- Setting up baud rate. Baud rate is the speed at which the computer/display device talks with the arduino board.
- Setting up I/O ports. Letting the mic-controller know which are the ports on which it is going to give outputs and the ones for inputs.
- This function is always executed only once, on the start of execution of the code or each time the arduino is resetted.
- void loop() - This function is the one resposible more the performance of the mic-controller.
- We know that the mic-controller loops a function again and again infinite times. That is the difference between a mic-controller and a mic-processor.
- A function which is to be executed continuously is written in void loop().
- A void loop can never be empty.
Other functions which are written outside the loop function must have a returning function to the loop. Because the loop is executed every time once the mic-controller is started.
BASIC SYNTAX -
Arduino coding is completely c++ and java based. So almost all syntaxes of java and c++ are used.
Stay tuned for further tutorials.....
BASIC SYNTAX -
Arduino coding is completely c++ and java based. So almost all syntaxes of java and c++ are used.
- For displaying data -
- serial.println("//data");
- serial.print("//data");
- For initializing variables -
- int variable ; // eg - int a;
- #define variable value ; // eg - #define a 10;
- After each statement, a semicolon (;) is used. Except in conditions and loop initialization.
- For comments, double hash (//) is used.
- To include a library -
- #include<library_name.h>
- Comparison -
- Equal to (==)
- Not equal to (!=)
- Greater than or equal to (>=)
- Less than or equal to (<=)
- Booloean and (&&)
- Boolean or (||)
- Boolean not (!)
- Increment (++)
- Decrement (--)
Stay tuned for further tutorials.....

No comments:
Post a Comment