19
Introduction to Arduino Seng Kang Secondary School Applied Learning Programme (ALP)

Lesson sample introduction to arduino

Embed Size (px)

Citation preview

Page 1: Lesson sample   introduction to arduino

Introduction to Arduino

Seng Kang Secondary School Applied Learning Programme

(ALP)

Page 2: Lesson sample   introduction to arduino

Lesson Objective

• What is Arduino• Parts of Arduino board• Programming codes / Arduino

Software

Page 3: Lesson sample   introduction to arduino

What is an Arduino?• Microcontroller board• Arduino can be used to develop interactive

objects, taking INPUTS (eg. Switches or sensors) and controlling physical OUTPUTS (eg. Lights or motors)

• The boards can be assembled by hand or purchased preassembled

Page 4: Lesson sample   introduction to arduino

Power in

USB (to computer)

Digital I\OPWM(3, 5, 6, 9, 10, 11)RESET

POWER 5V / 3.3V / GND

Analog INPUTS

Arduino

Page 5: Lesson sample   introduction to arduino

How Arduino works?

Human inputsEyeEar

NoseTongue

Skin

Output examples

Activate armsActivate legs

Activate mouth

Human brain

Output examples

Activate LEDsActivate Servo

Activate buzzer

Arduino inputsLight Sensors

Heart Rate sensors

Temperature sensors

Other inputs

Arduino Board

Page 6: Lesson sample   introduction to arduino

How Arduino works?

Arduino board blinks

the LED

Computer uploads

blinking LED code to Arduino board

Teacher shows how to connect the Arduino components

Student connects the

Arduino components

Student’s brain

Arduino Board

Page 7: Lesson sample   introduction to arduino

Digital Pins vs Analog Pins

• Digital Pin– There is two

modes (eg: ON/OFF)

• Analog Pins– Variable range (eg: dimming the light, different intensity)

Page 8: Lesson sample   introduction to arduino

Arduino Software(Sketch)

Page 9: Lesson sample   introduction to arduino

Light Emitting Diode (LED)

√ Polarity

Page 10: Lesson sample   introduction to arduino

Examples of LED

Page 11: Lesson sample   introduction to arduino

Activity: Blinking LED

Page 12: Lesson sample   introduction to arduino

Assemble

Negative leg LED GND

Positive leg LED Pin 13

Page 13: Lesson sample   introduction to arduino

Codes

• Step 1: Double click the icon to OPEN up the IDE

• Step 2: TYPE the code into the space below.

• Step 3: Click on to VERIFY the codes.

• Step 4: Click on to UPLOAD the codes to the board.

Page 14: Lesson sample   introduction to arduino

What does the codes means?

Page 15: Lesson sample   introduction to arduino

What do you observe after the

codes are uploaded?

Page 16: Lesson sample   introduction to arduino

End with a semi-colon ( ; )

const int led = 13;

void setup ()

{

pinMode (led, OUTPUT);

}

void loop ()

{

digitalWrite (led, HIGH);

delay(1000);

digitalWrite (led, LOW);

Delay (1000);

}

Declaration

Setup function(Preparation)

Loop function (Execution)

Open and close with curly brackets { }

Let’s Decode!!!

Page 17: Lesson sample   introduction to arduino

const int led = 13;

void setup ()

{

pinMode(led, OUTPUT);

}

void loop ()

{

digitalWrite (led, HIGH);

delay(1000);

digitalWrite (led, LOW);

delay(1000);

}

Declare LED as pin 13

Define LED as OUTPUT

HIGH LED On

LOW LED Off

Duration between blinks (In millisecond)

Page 18: Lesson sample   introduction to arduino

void loop ( )

{

digitalWrite (led, HIGH) ;

delay(1000);

digitalWrite (led, LOW);

delay(1000);

}

void loop ( )

{

digitalWrite (led, HIGH) ;

delay(500);

digitalWrite (led, LOW);

delay(500);

}

What do you observe after the codes are

changed?

Page 19: Lesson sample   introduction to arduino

Keywords• Arduino Board: Physical programmable circuit

board (also known as microcontroller)• Sketch: The name that Arduino uses for a

program. It is where the program codes are written.

• LED: Light Emitting Diode. Is an output.