Arduino Beginner - Lesson 3 - V3
Arduino Beginner - Lesson 3 - V3
Lesson 3
Introduction to Arduino
Presented by Advanced Superlogic Team
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 1
Learning Outcome
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 2
What is Arduino Digital Pins?
The pins on the Arduino can be configured as either
inputs or outputs. This document explains the
functioning of the pins in those modes.
pinMode()
pinMode(pin, mode)
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 3
Digital Inputs
pinMode()
pinMode(pin, INPUT)
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 4
Digital Outputs
pinMode()
pinMode(pin, OUTPUT)
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 5
Project Sample
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 6
Project: Control a LED on and off with
button
Parts Required
• Arduino board
• Breadboard
• Jumper wires
• LED
• four-pin pushbutton
• 10k-ohm resistor
• 1k-ohm resistor
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 7
How it works
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 8
Step 1: Connect button
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 9
Step 1: Connect button
When the pushbutton is open (unpressed) there is no connection between the two legs
of the pushbutton, so the pin is connected to ground (through the pull-down resistor)
and we read a LOW. When the button is closed (pressed), it makes a connection
between its two legs, connecting the pin to 5 volts, so that we read a HIGH.
You can also wire this circuit the opposite way, with a pullup resistor keeping the input
HIGH, and going LOW when the button is pressed. If so, the behavior of the sketch will
be reversed, with the LED normally on and turning off when you press the button.
If you disconnect the digital I/O pin from everything, the LED may blink erratically. This
is because the input is "floating" - that is, it will randomly return either HIGH or LOW.
That's why you need a pull-up or pull-down resistor in the circuit.
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 10
Step 2: Connect LED
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 11
Project: Control a LED on and off
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 12
Program
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 13
CHALLENGE
for : Lesson 1
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 14
L2 – Challenge 1
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 15
L2 – Challenge 2
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 16
L2 – Challenge 3
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 17
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 18
STEM | IR4.0 | Robotics Copyright 2023 © Advanced Superlogic Sdn Bhd. All right reserved. Arduino Beginner Lesson 1 19