Arduino Programming TRAINING
Arduino Programming TRAINING
Arduino Programming TRAINING
START
END
/* dan */ utk programming to be void. (line mana yang kita tak nak or spare)
delay = selamasa
BLINKING LED
+ 1K LED
pinMode(13,OUTPUT);
digitalWrite(13,HIGH); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
delay(1000);
digitalWrite(13,LOW); // LOW (OFF) // put your main code here, to run repeatedly:
delay(1000);
digitalWrite(13,HIGH); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
delay(1000);
}
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
Sambungan
5v
Gnd
Pin 13
Pin 13 digunakan sebagai output utk menghantar isyarat kepada LED supaya menyala.
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
2ND Project
2 LED BLINKING
+ 1K LED
1K LED
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
digitalWrite(13,HIGH); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
digitalWrite(12,HIGH); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
delay(1000);
digitalWrite(12,LOW); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
delay(1000);
digitalWrite(13,HIGH); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
digitalWrite(12,HIGH); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
delay(1000);
}
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
Sambungan
5v
Gnd
Pin 13
Pin 12
Sambungan pin 13 dan 12 digunakan bagi penyambungan LED supaya menyala. Kadar selamasa
bagi kelipan lampu ditentukan pada pengaturcaraan delay. 1000 = 1saat.
3RD Project
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
3 LED RUNNING LIGHT
+ 1K LED
1K LED
1K LED
-
void setup() { //jangan lupa setting dulu
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(8,OUTPUT);
digitalWrite(13,HIGH); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (OFF)
digitalWrite(12,LOW); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (OFF)
digitalWrite(8,LOW); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (OFF)
delay(500);
digitalWrite(12,HIGH); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (OFF)
digitalWrite(8,LOW); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (OFF)
delay(500);
digitalWrite(13,LOW); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (OFF)
digitalWrite(12,LOW); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (OFF)
digitalWrite(8,HIGH); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (OFF)
delay(500);
}
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
Sambungan
5v
Gnd
Pin 13
Pin 12
Pin 8
Hasil gabungan diantara 3 Led. Pengaturcara boleh mengubah suai litar utk nyalaan 3 Led secara
serentak atau berselang seli. Kadar selamasa ditentukan dalam aturcara delay.
*harus diingat, semua penyambungan led harus menggunakan perintang. Lazimnya pada kaki positif
Led.
4TH Project
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
TONE
+ PIN 7 BZZ
void setup() {
pinMode (7,OUTPUT);
tone (7,262,250);
delay (250);
tone (7,262,250);
delay (250);
tone (7,392,250);
delay (250);
tone (7,392,250);
delay (250);
tone (7,440,250);
delay (250);
tone (7,440,250);
delay (250);
tone (7,392,250);
delay (500);
5TH Project
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
3 LED WITH BUZZER
+ LED
1K
LED BUZZER
1K
1K LED
-
void setup() { //jangan lupa setting dulu
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(8,OUTPUT);
digitalWrite(13,HIGH); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
digitalWrite(12,LOW); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
digitalWrite(8,LOW); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
tone(11,220,1000);
delay(500);
digitalWrite(12,HIGH); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
digitalWrite(8,LOW); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
tone(11,247,1000);
delay(500);
digitalWrite(13,LOW); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
digitalWrite(12,LOW); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
digitalWrite(8,HIGH); // digitalWrite is a function that sends signal to a pin, turning it on or off. HIGH (ON)
tone(11,196,1000);
delay(500);
6th Project
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
POTENTIALMETER
Ground
Analog
Volt
*SELESAI PENYAMBUNGAN BUKA TOOLS SERIAL MONITOR UNTUK SEMAK NILAI RESISTOR
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
Sambungan
5v
Gnd
Pin A0
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
7TH PROJECT
Ground GND
5V
Volt
}void loop() {
}
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
Sambungan
5v
Gnd
Pin 13
*pengujian litar dimana Led akan menyala jika diberikan arus yang cukup, selain itu, litar boleh diuji
dgn mentol utk menguji keterangan dan kemalapan cahaya mentol tersebut.
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
8TH PROJECT
LDR
void setup() {
}
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
Sambungan
5v
Gnd
Pin A1
*Pengujian litar berlaku dengan menutup permukaan LDR bagi mendapatkan bacaan pada serial
monitor.
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
9TH PROJECT
void setup() {
}
Khairil Nizam Khairuddin
Smk Bandar Baru Batang Kali
Kursus KSSM Mikropemproses 2018
0146435314
Sambungan
5v
Gnd
Pin 5 = Led
*pengujian litar dimana Led akan padam jika permukaan Ldr ditutup, selain itu juga bacaan pada
serial monitor juga boleh diambil.