3-Arduino Program Sketch
3-Arduino Program Sketch
LEARNING
OBJECTIVES
3
Use the basic Arduino codes
to light-up the built-in led in
the microcontroller
codes
code
computer program
.ino
compiling
CODES
code
FUNCTION
1 void setup( ) {
2 // put your setup code here, to run once:
3
4}
code
SINGLE LINE
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
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
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
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!