Group H
Group H
SECTION 01
Lecturer: DR. TS. RAJA ZAHILAH BINT RAJA MOHD. RAZI
GROUP H
LAB 1
Blinking an LED Using an Arduino
1
1. Part 1
a. Coding of Part 1
- Default Code:
- Modified Code:
- void setup() {
- pinMode(13, OUTPUT);
- }
- void loop() {
- digitalWrite(13, HIGH);
- delay(1000);
- digitalWrite(13, LOW);
- delay(1000);
- }
2
figure 2
b. Question 1
- void setup() {
- pinMode(13, OUTPUT);
- }
- void loop() {
- digitalWrite(13, HIGH);
- delay(1000);
- digitalWrite(13, LOW);
- delay(1000);
- }
figure 3
We can change the number inside “delay(1000)” for both “HIGH” and
“LOW”, “HIGH” means high voltage level will turn the LED on, and
“LOW” means low voltage on the circuit will turn the LED off.
We can put any number there, HIGH > LOW (delay time) to make the
“on” time is longer than “off” time, LOW > HIGH to make the “off” time
is longer than “on” time, and LOW=HIGH to make it blink with the same
delay time (figure 3).
3
figure 4
2. Part 2
a. Coding of Part 2
- Update the previous Blink sketch code in the Arduino IDE to blink the
LED on the GPIO pin number 3.
- void setup() {
- pinMode(3, OUTPUT);
- }
- void loop() {
- digitalWrite(3, HIGH);
4
- delay(1000);
- digitalWrite(3, LOW);
- delay(1000);
- }
figure 5
b. Reflection