[go: up one dir, main page]

0% found this document useful (0 votes)
56 views11 pages

LAB 2 MSD Report

The document describes three exercises using an Arduino Uno to control LED blinking patterns. In the first exercise, a single LED is connected to pin 13 and programmed to blink on and off with a 1 second delay. The second exercise connects 8 LEDs to pins 2 through 9 and programs them to blink sequentially with a 1 second delay between each. The third exercise connects the same 8 LEDs in pairs and programs them to blink together with a 1 second delay between pairs. The results matched what was expected in each exercise, demonstrating control of LED blinking patterns using Arduino code.

Uploaded by

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

LAB 2 MSD Report

The document describes three exercises using an Arduino Uno to control LED blinking patterns. In the first exercise, a single LED is connected to pin 13 and programmed to blink on and off with a 1 second delay. The second exercise connects 8 LEDs to pins 2 through 9 and programs them to blink sequentially with a 1 second delay between each. The third exercise connects the same 8 LEDs in pairs and programs them to blink together with a 1 second delay between pairs. The results matched what was expected in each exercise, demonstrating control of LED blinking patterns using Arduino code.

Uploaded by

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

INDUSTRIAL AUTOMATION SECTION

FAB30104 Mechatronics System Design

Lab 2: Blinking LED

Objective:
To develop LED blinking pattern using Maker Uno.

Introduction:
The major use of LED (Light Emitting Diodes) is to illuminate objects and even places. Its application
is everywhere due to its compact size, low consumption of energy, extended lifetime and flexibility in
terms of use in various applications. This exercise will demonstrate on how to use an Arduino to
control LED as a prior knowledge due to lots of other sensors and modules are programmed the exact
same way.
Exercise 1
The Task:
1. I have created the simulation of LED Blinking project on the schematic diagram given
to us using Proteus software.
2. LED is connected with pin 13 in arduino board.
3. I have designed the programming code for arduino microcontroller using arduino IDE
software.
4. The code includes the blinking program and use delay () function which is going to
make the LED blinking in second, alternately ON and OFF.
5. After that, I open the arduino software to make the programming for the LED blinking
and uploaded the hex file into arduino microcontroller and click the play button/run
button.
6. The led blinking smoothly which LED is on and then OFF for a while (delay function).

Proteus Circuit:
Arduino Programming Code:

Result & Discussion:


After all the processes have been done, the LED was blinking on and off a second time
Interval within. In void loop(), the instructions are given by digitalWrite(LED1, HIGH). This
command specify what the LED1 will do either on or off by HIGH or LOW. HIGH means high
voltage will pass through thus turn the pin on and the other way for LOW. ON and OFF can
also being used besides HIGH and LOW. Next, delay time of the LED1 can also be
manipulated in sequence. Delay time system used in Arduino is millisecond i.e. “delay(1000)”
where the microcontroller will delay the voltage for 1 second. The LED will keep blinking
forever unless the circuit is open.
Exercise 2

The Task:
1. I have developed a schematic diagram based on the circuit given.
2. All the LED have been connected to pin 2 until 9 in arduino board.
3. Design the programming code which in the body loop, I included the LED blinking
program and use delay milliseconds () function which is going to make the LED
blinking one by one, alternately on and off.
4. To see the programming running, I uploaded the hex file into arduino microcontroller
and see the result.

Proteus Circuit:
Arduino Programming Code:

int led2 = 8; void setup() {


int led3 = 7; pinMode(9, OUTPUT);
int led4 = 6; pinMode(8, OUTPUT);
int led5 = 5; pinMode(7, OUTPUT);
int led6 = 4; pinMode(6, OUTPUT)
int led7 = 3; pinMode(5, OUTPUT);
int led8 = 2; pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
}
void loop() {
digitalWrite(9, HIGH); digitalWrite(3, HIGH);
delay(500); delay(500);
digitalWrite(9, LOW); digitalWrite(3, LOW);
delay(1000); delay(1000);
digitalWrite(8, HIGH); digitalWrite(2, HIGH);
delay(500); delay(500);
digitalWrite(8, LOW); digitalWrite(2, LOW);
delay(1000); delay(1000);
digitalWrite(7, HIGH); }
delay(500);
digitalWrite(7, LOW);
delay(1000);
digitalWrite(6, HIGH);
delay(500);
digitalWrite(6, LOW);
delay(1000);
digitalWrite(5, HIGH);
delay(500);
digitalWrite(5, LOW);
delay(1000);
digitalWrite(4, HIGH);
delay(500);
digitalWrite(4, LOW);
delay(1000);
Result & Discussion:
We can see all the LEDs will take turns to blink, one by one, ON AND OFF, with a 1second
interval within. Each of the LED will blink according to the code in arduino ide. Starting with
LED 8, it will ON, and OFF after 1000milisecond following to the delay function - delay
(1000); and continue with LED8 to ON, and OFF after 1 second and go on the process until
LED2 then it will start looping back to LED8 and keep continuing the process. In void loop(),
we still use the same instructions, which is, digitalWrite(LED, HIGH) and for all the LED.
This command specifies what the LEDs will do either on or off by HIGH or LOW. HIGH
means high voltage will pass through thus turning the pin on and the other way for LOW. ON
and OFF can also be used besides HIGH and LOW. The void loop() runs over and over again.
These commands will make the LED blink, and with the code continuing, from LED8 to
LED1, the LED will be ON and OFF and keep looping with delay.
Exercise 3:

The Task:
1. Using the previous schematic diagram, I need to change the programming code.
2. used the same LED blinking program and delay_ms() function, but in order to make the
led blinking according to the diagram given, I have changed the code to double the
LED inside the same paragraph.
3. I need to activate the LEDs at pin 2 until pin 9 to blink in duo mode, LED1 and LED2,
LED3 and LED4, LED5 and LED6 and lastly LED7 and LED8.
4. After that I uploaded the hex file into the microcontroller, I run the circuit to see the
result.

Proteus Circuit:
Arduino Programming Code:
int led2 = 8; void setup() {
int led3 = 7; pinMode(9, OUTPUT);
int led4 = 6; pinMode(8, OUTPUT);
int led5 = 5; pinMode(7, OUTPUT);
int led6 = 4; pinMode(6, OUTPUT);
int led7 = 3; pinMode(5, OUTPUT);
int led8 = 2; pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
}
void loop() {
digitalWrite(9, HIGH); digitalWrite(3, HIGH);
digitalWrite(8, HIGH); digitalWrite(2, HIGH);
delay(1000); delay(1000);
digitalWrite(9, LOW); digitalWrite(3, LOW);
digitalWrite(8, LOW); digitalWrite(2, LOW);

digitalWrite(7, HIGH); digitalWrite(5, HIGH);


digitalWrite(6, HIGH); digitalWrite(4, HIGH);
delay(1000); delay(1000);
digitalWrite(7, LOW); digitalWrite(5, LOW);
digitalWrite(6, LOW); digitalWrite(4, LOW);

digitalWrite(5, HIGH); digitalWrite(7, HIGH);


digitalWrite(4, HIGH); digitalWrite(6, HIGH)
delay(1000); delay(1000);
digitalWrite(5, LOW); digitalWrite(7, LOW);
digitalWrite(4, LOW); digitalWrite(6, LOW);

}
Result & Discussion:
As a result, the LEDs will be blinking in duo mode, ON and OFF, pair by pair (LED1
with LED2, LED3 with LED4, LED5 with LED6, and lastly LED7with LED8). It will take
turn alternately with delay_ms() function, 1000 milliseconds, each pair will be blinking, take
turn to ON and OFF. In the void loop (), the LED have been paired up in duo mode, which
each pair will be code in each paragraph for example.
digitalWrite(9, HIGH); digitalWrite(3, HIGH);
digitalWrite(8, HIGH); digitalWrite(2, HIGH);
delay(1000); delay(1000);

as this command specifies what the paired LEDs will do either on or off by HIGH or LOW.
HIGH means high voltage will pass through thus turning the pin on and the other way for
LOW. ON and OFF can also be used besides HIGH and LOW. Thus, the function of this
command is to make the LEDs, blinking in pair, ON and OFF, pair by pair and it will continue
to loop.

Conclusion:
The blinking LED circuit using the arduino maker was simulated, built, and tested. All
the LEDs were blinking according to the code I have programmed. All the output turns
out as expected. The objective that we set out to achieve in the purpose were all
achieved as we proved in all the exercises. Similarly, the whole process was
documented in the schematic and theory sections. Thus, these exercises have taught
me the basic of using arduino maker and make me familiar with the code as a
beginner.

You might also like