Nota Arduino Kursus Daerah Hulu TRG
Nota Arduino Kursus Daerah Hulu TRG
1
House Rules 2
1
BE ON TIME
2
ASK QUESTIONS &
PARTICIPATE
6
BE RESPECTFUL
4
REDUCE USAGE OF PHONES
5
CLASS-YES
Objektif Pembelajaran 3
Objektif Pembelajaran 4
Kriteria Kejayaan 5
• Novice
• Complete 1 or 2 challenges
• Amateur
• Complete almost all challenges
• Master
• Complete all challenges
Pembahagian Masa 6
• Sesi 1: (3 jam)
• Apakah itu mikropengawal
• Litar Output / Asas Pengaturcaraan
• Sesi 2: (1.5 jam)
• Litar Input
• Sesi 3: (1.5 jam)
• Struktur Kawalan Pilihan
• Penghasilan Projek Mini
What is Arduino? 7
https://www.youtube.com/watch?v=9vQY2oTrLkY
What words would you associate Arduino with? 8
It’s everywhere!
Microcontroller is a
mini computer that can
be programmed to
control electronic
components
Microcontroller communicates in binary 9
Start
Start
setup program
loop program
Open Your Arduino Program 12
Install Driver
Connect your microcontroller to the computer 15
Your First Program! 16
Start
Wait 1 second
Wait 1 second
End
Setting Up 17
Click upload
Does it blink?
NO!
What’s the problem? 22
Start
Wait 1 second
Wait 1 second
End
23
Does it blink?
YES!
26
Pin 13
HIGH
27
Pin 13
LOW
Blink 2 LEDs together 28
Blink 2 LEDs together 29
Bil Tugasan
A1 Kelipkan LED pada
pin 5 setiap 1 saat
A2 Kelipkan 2 LED
bersama-sama setiap
0.5 saat
A3 6 LED Countdown
A4 6 LED Corak chase-
light
Let’s Make a Circuit! 31
Breadboard
Resistors 32
Light Emitting Diodes (LED) 33
What is a circuit? 34
220
Circuit 1 – Controlled by Arduino 36
Circuit 1 – Controlled by Arduino 37
Is this connection okay?
Schematic for connecting 1 LED at Pin 13 38
Connecting 2 LEDs 39
Take turns to turn on
Schematic for connecting 6 LEDs ? 40
Schematic for connecting a buzzer 41
Suis untuk mengaktifkan
pembaz Breadboard
Pembaz
Tone function 42
Bil Tugasan
B1 Lampu Isyarat
B2 Persembahan muzik dan
lampu
B3 Ulangi A3 atau A4 dengan
LED yang sambung di
breadboard
Potentiometer 46
Positive (5V)
Ground (GND)
To analog pin
(A0 – A5)
Code to read input 47
analogWrite(Pin, value)
BONUS – Using the value in analogWrite 50
BONUS – Using the value in analogWrite 51
Light Dependent Resistor 52
Connecting LDR 53
Connecting LDR 54
Code for LDR? analogRead as well! 55
Challenge C 56
Bil Tugasan
C1 Buat penyelidikan atas talian untuk
carikan kegunaan analogWrite.
Nyalakan 1 LED dengan analogWrite
Input Output
Process and
Decide
It’s all about deciding! 58
Decision Making Flowchart 59
TRUE FALSE
CONDITION
A B
Start
Read input
from A1
TRUE FALSE
Is A1 less than
500?
End
Challenge D 62
Bil Tugasan
D1 Hidupkan LED jika gelap
D2 Hidupkan 3 LED jika nilai
potentiometer adalah lebih daripada
800. Kalau tidak, hidupkan 1 LED
63
Advanced Topic
More than 1 situation 64
Logic Operator 65
Advance Ranging 66
1 LED
1 LED
1 LED
If (x > 250)
If ( !(x<250) )
Advance Ranging 69
Bil Tugasan
E1 Semakin gelap, semakin
banyak LED dinyalakan
E2 Bilangan LED yang
dinyala boleh dikawal
dengan memutar perintang
boleh laras
Resources 71
arduino.cc
instructables.com
makeruno.com.my
https://goo.gl/8AZwj4
cytron.io
Sekian Terima Kasih
Breadboard
Suis untuk
74
mengaktifkan pempaz
Pembaz
75