Getting Started With Arduino

The Arduino Developing Board

 



Detailed PINOUT Diagram

 

The Arduino IDE


Parts of the IDE (From left to right, top to bottom)

· Compile - Before your program “code” can be sent to the board, it needs to be converted into instructions that the board understands. This process is called compiling.
· Create New Sketch - This opens a new window to create a new sketch.
· Open Existing Sketch - This loads a sketch from a file on your computer.
· Save Sketch - This saves the changes to the sketch you are working on.
· Upload to Board - This compiles and then transmits over the USB cable to your board.
· Serial Monitor  We can simulate and monitor serial communication with the help of Serial Monitor.
· Sketch Editor This is where you write or edit sketches.
· Text Console - This shows you what the IDE is currently doing and also displays any error messages if you make any mistake in typing your program (i.e. syntax error).
· Line Number This shows you what line number your cursor is on. It is useful since the compiler gives error messages with a line number

Arduino programs can be divided in three main parts: 

 Structure
 Values (Variables and Constants)
 Functions

 

STRUCTURE

The basic structure of the Arduino Programming Language is fairly simple and runs in at least two parts, or functions, enclose blocks of statements.

void setup()
{
  // Initialize the PORTs, variables, etc. here. Runs only once:
}

void loop()
{
  // Write your code here that gets continuously executed:
}
  • Where setup() is preparation and loop() is the execution.
  • Both functions are required for the program to run.

setup()

  • Called once when your program starts.
  • Used to initialize pin modes, begin serial,…… etc.
  • It must be included in the program even if there are no statements to run.
void setup()
{
  pinMode(13, OUTPUT);      //Set the PIN13 as output.
}

loop()

 Loop continuously allowing the program to change, response and controlling the Arduino board.

void loop()
{
  digitalWrite(13, HIGH);           //Set pin13 High.
  delay(1000);                           //Wait for 1 sec.
  digitalWrite(13, LOW);            //Set pin13 Low.
  delay(1000);                           //Wait for 1 sec.
}

 pinMode()

It is used to define behavior of PORT pin either INPUT or OUTPUT.

digitalWrite()

It is used to make PORT pin either logic HIGH(1) or logic LOW(0).

delay()

It is time delay(wait) in millisecond, i.e. 1000 miliSeconds=1 sec.

Download Arduino from Following link:



Comments