0% found this document useful (0 votes)
5 views15 pages

Arduino Programming Basics and Syntax

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views15 pages

Arduino Programming Basics and Syntax

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

STEAM: Circuits

and IoT
[Link]
Objectives
At the end of the lesson, you should be able to:

a. Define program;

b. Analyze the different Arduino syntax; and,

c. Program the circuit


[Link]
What is a
Program?
Program is a written language which enables a
computer to perform its function.
[Link]
What is a
Program?
Arduino uses C / C++ Programming language. C was
created by Dennis Ritchie between 1969 -1973 and in 1979,
Bjarne Stroustrup created C with classes known as C++.
[Link]
Sensors Actuators
receives signals or stimulus actuates or moves
from an environment or something - converts
physical system. Converts electrical signal into actions.
stimulus into electrical
signal.
[Link]
Types of
Signals

Digital Analog
is represented by 2 can take up any number
values: either High or of values or readings
Low or on or off. (example temperature)
[Link]
Basic programming
syntax
[Link]
ARDUINO IDE
[Link]
New
Open
Sketch
Upload Sketch

Verify Save Sketch Serial Monitor

Programming
area

Debugging
Console
[Link]
VOID loop
VOID setup (){}
(){}

Void setup is technically a


function that you create at the The loop is another function
top of each program. Inside that Arduino uses as a part of
the curly brackets is the code its structure. The code inside
that you want to run one time the loop function runs over
as soon as the program starts and over as long as the
running. You set things like board is turned on.
pinMode in this section.
[Link]
Programming syntax
; {} ()
(semicolon) curly bracket parentheses
The end of a command A group of code
A group of arguments
or statement. The statements. You always
for a function, a
compiler doesn't look for need a closing curly
method, or a code
spaces in your code, it brace to match each
statement.
looks for semicolons opening curly brace.

, // /* */
(comma) single line comment multi-line comment

It separates and When you type two Comment starts with


evaluates each of its forward slashes, the code the /* and doesn't
arguments (from left to from that point until the
[Link]

end until the */


right). end of that line is ignored characters.
by the compiler.
pinMode();

is used to configure a specific pin to behave either


as an input or an output.

PIN NUMBER INPUT or OUTPUT


[Link]
digitalWrite();
digitalWrite() is the command that allows you to send 5V or
0V to an output pin. digitalWrite() takes two arguments:
what pin to control, and what value to set that pin, HIGH
or LOW.

HIGH = ON
PIN NUMBER
[Link]

or
LOW = OFF
delay();
The delay() function lets you stop the Arduino from executing
anything for a period of time. delay() takes an argument that
determines the number of milliseconds before it executes the
next set of code. There are 1000 milliseconds in one.
[Link]

milliseconds
Variable
is a way of naming and storing a value for later use by the program.

INTEGER (int) FLOAT (float) STRING (string)

Integers are your Data type for


floating-point A data type used
primary data-type to store texts.
for number numbers, a number
storage. that has a decimal
point.

CHARACTER (char) BOOLEAN (bool)

A bool holds one of


[Link]

A data type used to two values, true or


store a character value. false.

You might also like