0% found this document useful (0 votes)
14 views5 pages

Group H

This document summarizes an Arduino lab experiment on blinking an LED. The experiment has two parts: 1) The first part involves coding an Arduino sketch to blink an LED connected to pin 13. It explains how to initialize the pin as an output and use digitalWrite and delay commands to turn the LED on and off to create a blinking effect. 2) The second part modifies the sketch to blink the LED on pin 3. It asks what issues could cause the LED to fail blinking and answers that wiring errors or using the wrong serial port could cause failures.

Uploaded by

angwin s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views5 pages

Group H

This document summarizes an Arduino lab experiment on blinking an LED. The experiment has two parts: 1) The first part involves coding an Arduino sketch to blink an LED connected to pin 13. It explains how to initialize the pin as an output and use digitalWrite and delay commands to turn the LED on and off to create a blinking effect. 2) The second part modifies the sketch to blink the LED on pin 3. It asks what issues could cause the LED to fail blinking and answers that wiring errors or using the wrong serial port could cause failures.

Uploaded by

angwin s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SECR4973 - SPECIAL TOPIC IN COMPUTER

NETWORKS AND SECURITY

SECTION 01
Lecturer: DR. TS. RAJA ZAHILAH BINT RAJA MOHD. RAZI

GROUP H

Hafizh Nailul Authar


Muhammad Angwin Sayrestian

LAB 1
Blinking an LED Using an Arduino

1
1. Part 1

a. Coding of Part 1

- Default Code:

// the setup function runs once when you press reset


or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever


void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on
(HIGH is the voltage level)
delay(1000); // wait for a
second
digitalWrite(LED_BUILTIN, LOW); // turn the LED
off by making the voltage LOW
delay(1000); // wait for a
second
}
figure 1

“pinMode(LED_BUILTIN, OUTPUT);” is the code that we use to


initialize a digital pin as an output, “LED_BUILTIN” here is the
pin that we want to use and need to change later.

- Modified Code:

- void setup() {
- pinMode(13, OUTPUT);
- }
- void loop() {
- digitalWrite(13, HIGH);
- delay(1000);
- digitalWrite(13, LOW);
- delay(1000);
- }

2
figure 2

- As we can see, “LED_BUILTIN” from figure 1 has already


changed to “13”, because we are going to use pin number 13 on
the circuit board.

b. Question 1

How can you change the blinking rate?

- 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

This is the output from figure 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

What issues could cause the failure of the LED to blink?

- There is an error in the installation of LED or power cable and jumper.


- The wrong port was chosen to be used, we can check it in the Control
Panel > Device Manager > Ports.

You might also like