REKA BENTUK TEKNOLOGI
ARDUINO
MICROCONTROLLER
Product Training and Demonstration
MYSCHOLAR TEACHING RESOURCES
TH Lau 012-7010498
B. Of Materials Engineering (NTU, Singapore)
M.Bus in IT (Curtin University, Australia)
AGENDA
1.0 BASIC CONCEPT AND DEMO
What is Microcontroller
Arduino Board Close Look
Input and Output / Analog vs Digital
Revision of Full Concept
Application Demonstration – Car Reverse Sensor
AGENDA
2.0 CODING AND PROGRAM
Basic Syntax and Rule
Arduino Programming with 2 projects
Play with S4A Program
3.0 HOW TO USE MYSCHOLAR ARDUINO KIT
Kit Set Introduction (components, manual and CD)
Tips on Workshop and Best Learning Approach
REKA BENTUK TEKNOLOGI
1.0 BASIC CONCEPT AND
PRODUCT DEMO
MYSCHOLAR TEACHING RESOURCES
TH Lau 012-7010498
B. Of Materials Engineering (NTU, Singapore)
M.Bus in IT (Curtin University, Australia)
WHAT IS MICRO-CONTROLLER
• Using single-board microcontroller and kits for building
digital devices and interactive object
• The board can sense and control objects in the physical world
• 3 sets of components –
Input Microcontroller Output
Sound, Light, Board LED, Buzzer, Motor,
Temp Sensor, Servo, LCD Display
Switch & Program
Control)
ARDUINO BOARD CLOSE LOOK
Power Seat for USB interface
external Power (5v Power Entry)
Supply (7V to 12V)
Reset button
Microcontroller
[CPU, ROM,
RAM & I/O PIN]
Ground Point
Power Supply
and 2 Ground 12 Digital Pin for
Point Input/Output
(Pin2 to Pin13)
6 Analog Input Be it Input or Output?
We program it in sketch
TYPE OF INPUT FOR ARDUINO
Analog Digital
Input
Most sensors are analog All switches are digital
(PIR/Motion Sensor is digital)
Character • Indefinite • Discrete
• Continuous • Step, not continuous
• 1.1, 1.11, 1.2, 1.25, 1.257, 1.556 • 0 and 1, Yes or not
• Sound, Light, Heat • Push Button, Switch
Analog sensors on the left Digital Switches on the right
REVISION OF CONCEPT
INPUT OUTPUT
Program Input Arduino Board with LED Light
Push Button Buzzer
Micro Controller
Switch LCD
Temp Sensor Motor
Gas Sensor Robot
LDR Sensor etc
Input
Program
PC/Laptop/Tablet/Handphone
Need to Input Sketch (program)
into the Arduino Board!
The system can operate by itself without any
connection again!
REAL LIFE EXAMPLES OF MICRO CONTROLLERS
MYSCHOLAR ARDUINO KIT
No Project Name Application
1 LED Blinking Traffic
2 Push Button/Limit Switch Toilet Door
3 LED Switching Traffic Light
4 Potentiometer Blinking Frequency
5 LED Fading Light Intensity Variation
6 LED Scrolling Festival Decoration
7 RGB Display Different Color Display
8 Buzzer Alarm Door Bell, Entry Alarm
9 LDR Auto Light Switch Smart Lighting System
10 LDR Proximity Alarm Car Reverse Sensor
11 Temperature Sensor Display Temperature Reading
12 Servo Robotic Motion
EXPLOLATION ON OTHER PROJECTS
Project Name Additional Component Application
1 Temperature Display LCD Module LCD Displaying Temperature
2 Rain is coming Rain Sensor Module Alerting Rainfall
Carpark Capacity Measure
3 What is the number now? Segment Bank Queueing System
4 Fire! Fire!! Gas Sensor Fire Alarm
5 Catch The Theft IR Sensor Motion Detector
6 How far are you Ultrasonic Measure Distance
7 Clap-clap Sound Sensor Sound Control Light
Jangan Tekan Lagi! Nak Detecting Breaking
8 Pecah! Flexible Bend Sensor Component
9 Servo Application Servo Motor Robotic
10 Motor Motion DC Motor Racing Car
CAR REVERSE SENSOR DEMONSTRATION
• Triggered by Reverse Gear
• Closer to the objects, more urgent the beep sound
• We use LDR (Light Dependent Sensor) to do the
demonstration
INPUT OUTPUT
LED
LDR Buzzer
Sensor
CAR REVERSE SENSOR LOGIC
LDR Value proportional with light received
Start Reverse Gear, turn on
300 Sensor, LDR value >300
Detecting objects, LDR value in
between 150 and 300
150
Very close to the object, LDR
value < 150!!
0
LDR Value
CAR REVERSE SENSOR SETUP STEP
Step 1. Setup Hardware
Step 2. Startup Arduino IDE (Integrated Development
Environment) Program
Step 3. Upload of sketch (code) into Arduino Board
Step 4. Unplug USB interface, plug in battery
HARDWARE SETUP FOR CAR SENSOR
OUTPUT
INPUT
SKETCH ANALYSIS
(CODING ANALYSIS)
1. Set Pin Number
3. Set Condition
2. Define Input and Output
REKA BENTUK TEKNOLOGI
2.0 ARDUINO CODING
AND PROGRAM
MYSCHOLAR TEACHING RESOURCES
TH Lau 012-7010498
B. Of Materials Engineering (NTU, Singapore)
M.Bus in IT (Curtin University, Australia)
UNDERSTANDING CODING (SKETCH)
• Coding is important
• It is one of the key components in micro-controller
• In Arduino, the coding program is called ‘Sketch’ and it’s written in
Arduino IDE (INTEGRATED DEVELOPMENT ENVIORNMENT)
• Understanding coding helps you understand how your mirco-
controller functions
TO UNDERSTAND CODING
DOESN’T
MEAN ASKING YOU TO WRITE
COMPLICATED PROGRAM
We demonstrate simple program writing and introduce S4A program
that simulates your own program!
BLINKING PROGRAM CODING
void setup()
{ pinMode (13, OUTPUT);
}
void loop()
{ digitalWrite(13, HIGH);
delay (1000);
digitalWrite(13, LOW);
delay(1000);
}
PUSH BUTTON PROGRAM
const int buttonPin = 2;
const int ledPin = 13;
int buttonState = 0;
void setup()
{ pinMode (buttonPin, INPUT);
pinMode (ledPin,OUTPUT); }
void loop()
{ buttonState = digitalRead(buttonPin)
If (buttonState = HIGH )
{ digitalWrite (ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW); }
}
BASIC SYNTAX AND BASIC RULE
• setup() Setting Pin Mode, eg. INPUT or OUTPUT
• loop() Main Program written inside here
• ; Semicolon keyed in after each command. The IDE do not
understand ‘ENTER’
• {} Curly Brace. Must be in pair. Insert statement or condition inside
• // Single line comment. IDE ignore what you have written after // in
the same line
• /*……*/ Block comment. Must be in pair. IDE ignore what you have
written inside the block comment
BASIC SYNTAX AND BASIC RULE
• int Integers. Define a variable in integer type (0, 1, 13
etc). Can be used in naming pin number also
• digitalWrite(pin, HIGH) Write High (5V) or Low (0V)to the specific digital
• digitalWrite(pin, LOW) pin number specified
• digitalRead(pin) Reads the value from a specified digital pin,
either HIGH or LOW.
• delay (ms) Pause the time in millisecond. Delay(5000) means
delay 5 second
• if()…else
Setting up condition
BLINKING PRORAM HARDWARE SETUP
Input = Program
Output = LED
WRITING BLINKING PROGRAM
void setup()
{
pinMode (13, OUTPUT); //define pin#13 as output pin
}
void loop()
{ digitalWrite(13, HIGH); //send 5V to pin 13, LED turned on
delay (1000); //delay 1 second
digitalWrite(13, LOW); //send 0V to pin 13, LED turned off
delay(1000); //delay 1 second
}
PUSH BUTTON HARDWARE SETUP
INPUT = PUSH BUTTON
OUTPUT = LED LIGHT
PUSH BUTTON PROGRAM
const int buttonPin = 2; //name the pin2 to be buttonPin
const int ledPin = 13; //name the pin13 to be ledPin
int buttonState = 0; //define an integer 0 or 1 to determine the button state
void setup()
{ pinMode (buttonPin, INPUT); //define pin#2, buttonPin as input pin
pinMode (ledPin,OUTPUT); //define pin#13, ledPin as output pin }
void loop()
{ buttonState = digitalRead(buttonPin) //read the button pin state
If (buttonState = HIGH ) // the button is pressed
{ digitalWrite (ledPin, HIGH); //turn the LED on
}
else
{
digitalWrite(ledPin, LOW); //turn the LED off }
}
QUESTION??
HARD TO LEARN??
WE COULD START FROM S4A
(SCRATCH FOR ARDUINO) PROGRAM
ARDUINO LEARNING PROGRAM S4A
S4A – Scratch For Arduino
Graphic User Interface – ‘Play with
LEGO Block’
Fun and Simple, Easier to
Understand. No Coding!
How It works?
Sending a ‘translator’ sketch to the
Arduino Board
‘Translator’ sketch would help you
to translate your GUI command to
machine understood language
UNDERSTANDING S4A
Input Translator Program
Hi There! My name is ‘S4AFirmware16.ino!
I’ll do the translation for you!!
THE PURPOSE OF S4A PROGRAM
1. Learn Programming Easier,
because NO Syntax error
2. Understand your program logic
flow Easier
3. Learn to write C++ Easier by
comparing both S4A coding and
C++ coding
We Have Provided 12 Projects in both coding for You!
REMEMBER: The code in the micro processor
is still “The Translator”, not the working code!!
Plug out from PC, the system becomes useless!
S4A PROGRAM
DEMOSTRATION
REKA BENTUK TEKNOLOGI
HOW TO USE MYSCHOLAR
ARDUINO KIT
MYSCHOLAR TEACHING RESOURCES
TH Lau 012-7010498
B. Of Materials Engineering (NTU, Singapore)
M.Bus in IT (Curtin University, Australia)
HOW TO MAKE GOOD USE OF THIS KIT
1.0 KITS INTRODUCTION
2.0 MANUAL INTRODUCTION
3.0 CD INTRODUCTION
4.0 TIPS IN WORKSHOP AND THE BEST LEARNING
WAY
1.0 KITS INTRODUCTION
ABOUT THE COMPONENTS
No Key Parts Qty
1 UNO board with USB Cable 1 unit
2 Half Size Bread Board 1 unit
3 20cm Male to Male Jumper 40 pcs
4 220Ohm Resistor 10 pcs
5 10K Ohm Resistor 10 pcs
6 5mm LED (RED, GREEN, BLUE, YELLOW) 15 pcs
7 5mm RGB LED 1 unit
8 Potentiometer 1 unit
9 Push Button 1 unit
10 Limit Switch 1 unit
11 Buzzer (PCB Mount) 1 unit
12 Temperature Sensor LM35 1 unit
13 Proximity Sensor (LDR) 2 unit
14 TowerPro SG90 Servo Motor 1 unit
15 9V DC Power Connector 1 unit
16 MyScholar Arduino Project Manual 1 unit
17 Container Box 1 unit
1.0 KITS INTRODUCTION
ABOUT THE PROJECTS
No Project Name Application
1 LED Blinking Traffic
2 Push Button/Limit Switch Toilet Door
3 LED Switching Traffic Light
4 Potentiometer Blinking Frequency
5 LED Fading Light Intensity Variation
6 LED Scrolling Festival Decoration
7 RGB Display Different Color Display
8 Buzzer Alarm Door Bell, Entry Alarm
9 LDR Auto Light Switch Smart Lighting System
10 LDR Proximity Alarm Car Reverse Sensor
11 Temperature Sensor Display Temperature Reading
12 Servo Robotic Motion
2.0 MANUAL INTRODUCTION
2.1 Concept and Installation
2.2 Component Introduction
2.3 Project Details
2.0 MANUAL INTRODUCTION
2.1 Concept and Installation
2.0 MANUAL INTRODUCTION
2.2 Component Introduction
2.0 MANUAL INTRODUCTION
2.3 Project Details
2.3.1 Components Required List
2.3.2 Project Diagram
2.3.3 Concept Emphasis
2.3.4 Explanation on the System
2.3.5 Simple KBAT Exercise
3.0 CD INTRODUCTION
ABOUT THE CD
4.0 TIPS IN WORKSHOP &
THE BEST LEARNING WAY
• Standardize use of wire color in any circuit. Make troubleshooting
easier. For Examples,
Red for Power Supply Black for Grounding
Green for Analog Sensor Blue for LED
• During troubleshooting, always start from identifying the
INPUT and OUTPUT circuit
• Swapping components to confirm the root cause
• Assign Projects According to student capability
We have 12 projects with all IDE and S4A coding ready
• Learn to write code with the help of S4A and by comparing the
coding of S4A and IDE 12 Projects provide 24 examples
• Hands On is always the Best Learning Approach
Please call us for any enquiry or additional
component order
We can be reached at :
TH Lau : 012-7010498
Faridz : 012-7943898
Office : 012-7125298/07-4332298
Thanks for your time