Arduino IDE Integrated Development Environment
Arduino IDE Integrated Development Environment
Integrated Development
Environment
PREPARED BY:
CHRISTOPHER JOHN I. GAYTA, ECE, ECT
Arduino Sketch
Arduino sketch is the name that setup()
Arduino uses for a program.
It’s the unit of code that is loop()
uploaded to and runs on an
Arduino board.
Running the first code in Arduino
UNO
Setup () and Loop () Functions
void setup() void loop()
{ {
} }
executed only once when run continuously from top
the sketch is run to bottom and then back
to the top
{
is the opening brace of the
functions that tells that all
statements starting from here
are inside the function.
}
is the closing brace of the
function.
;
is used to terminate
the statement.
Serial.begin(9600);
This statement sets up
the speed of the serial
port to 9600 baud.
Serial.println(“Hello World”);
void setup()
{ A variable is a place to
Serial.begin(9600); store a piece of data. It has
}
a name, a value, and a type.
void loop() For example, this statement
{
count = count + 1;
(called a declaration):
Serial.println(count);
}
Global variables are
declared outside any
function, and they can be
accessed (used) on any
function in the program.
bool var = 0;
var variable will have a value of 0
DATATYPE:
float var = 0.1;
float
var variable will have a value of 0.1
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
digitalWrite(pin, HIGH or LOW)
write a digital pin, to a HIGH or LOW value
map (variable, old low, old high, new low, new high);
COMPARISON OPERATOR
BOOLEAN OPERATOR
if STATEMENT