Professional Documents
Culture Documents
MyScholar Arduino Training
MyScholar Arduino Training
ARDUINO
MICROCONTROLLER
Microcontroller
[CPU, ROM,
RAM & I/O PIN]
Ground Point
Power Supply
and 2 Ground 12 Digital Pin for
Point Input/Output
(Pin2 to Pin13)
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
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
INPUT
SKETCH ANALYSIS
(CODING ANALYSIS)
3. Set Condition
}
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
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
void loop()
{ buttonState = digitalRead(buttonPin) //read the button pin state
}
QUESTION??
HARD TO LEARN??