0% found this document useful (0 votes)
9 views28 pages

3-Arduino Program Sketch

Uploaded by

rickynimanzano
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)
9 views28 pages

3-Arduino Program Sketch

Uploaded by

rickynimanzano
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
You are on page 1/ 28

Program sketch

LEARNING
OBJECTIVES

1 Explain how the Arduino IDE creates,


interpret and download a sketch

2 Identify and create the basic


arduino codes

3
Use the basic Arduino codes
to light-up the built-in led in
the microcontroller
codes
code

computer program

electronic device to perform its task


programmer
computing
code

.ino
compiling

syntax machine language


executing
;
program
terminator
case
sensitive
code

CODES
code

FUNCTION
1 void setup( ) {
2 // put your setup code here, to run once:
3
4}
code
SINGLE LINE

1 // this is a single line comment


2 // another single line comment
3 void setup( ) {
4 // another single line comment in void setup
code
MULTILINE

1 /* Group Names
2 8 – Red
3 Activity 03 – / volume indicator
4 September 11, 2019
5 */
code

FUNCTION
1 void loop( ) {
2 // // put your main code here, to run repeatedly:
3
4}
DIGITAL
DIGITAL

digital pin 13
DIGITAL

FUNCTION
1 void setup( ) {
2 // put your setup code here, to run once:
3 pinMode(13, OUTPUT);
4}
DIGITAL

FUNCTION

6 void loop( ) {
7 // put your main code here, to run repeatedly:
8 digitalWrite(13, HIGH);
9 digitalWrite(13, LOW);
10 delay(1000);
11 }
FUNCTION
FUNCTION

pinMode( ) function is used to set up a


specific pin as either digital input or
digital output.
Syntax
pinMode(pin, MODE);
FUNCTION

Parameters
pin : specific number of the pin it is
connected in the board
MODE : INPUT, OUTPUT
FUNCTION

Example
1 void setup( ) {
2 // put your setup code here, to run once:
3 pinMode(13, OUTPUT);
4}
FUNCTION
FUNCTION

digitalWrite( ) function writes


either HIGH or LOW value to a digital pin

HIGH value will set up the pin for 5V or


3.3V and 0V (ground) for LOW value
FUNCTION

Syntax
digitalWrite(pin, VALUE);
Parameters
pin : OUTPUT pin number
MODE : HIGH, LOW
FUNCTION

Example
6 void loop( ) {
7 // put your main code here, to run repeatedly:
8 digitalWrite(13, HIGH);
10 digitalWrite(13, LOW);
11 delay(1000);
12 }
FUNCTION
FUNCTION

digitalWrite( ) function causes the


program to pause for a specific period of
time in miliseconds before executing the
next line of codes. One second is
equivalent to 1000 milliseconds.
FUNCTION

Syntax
delay(ms);
Parameters
ms : number of millisenconds to
pause
FUNCTION

Example
6 void loop( ) {
7 // put your main code here, to run repeatedly:
8 digitalWrite(13, HIGH);
10 digitalWrite(13, LOW);
11 delay(1000);
12 }
Program sketch
– end –
THANK YOU!

You might also like