Arduino Programming

Programming Arduino is easy if you have some basics of any programming language. But if you know the c or c++ then it will be easier. It is simply a set of C/C++ functions. So we can call/use it from anywhere in the arduino code. Here in arduino a program is called as sketch. If we talk about “C” language a program contains some header files and function main() in all programs. It is just like a body of C Program.
In Arduino, a sketch containing the function setup() and loop(). So a basic sketch or program looks like this…

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

setup() is a function that runs only once and we use it generally for initialization or code you want to run it once. A loop() is a function that repeats continuously. So if you need to execute some code every time like refreshing screen, reading sensor value etc then place the code here.

LED Blinking Program

This is the very basic program for the beginners. We upload the sketch to the arduino board and on board led starts blinking.

// the setup function runs once when you press reset or
// power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on 
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off
  delay(1000);              // wait for a second
}

How to Start Learning Arduino

We can learn arduino online by official arduino website or also available in arduino software Help->Reference. Once you have an understanding of arduino syntax and its library function do some Arduino Tutorials with different peripherals.

Leave a Reply

Your email address will not be published. Required fields are marked *