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

Lab 1: Digital Input and Output: Task 1: Blinking An Led

The document describes four tasks in an Arduino lab involving digital input and output using LEDs and pushbuttons. Task 1 involves blinking an LED using the Arduino code. Task 2 blinks LEDs using a pushbutton. Task 3 adds multiple blink modes controlled by the pushbutton count. Task 4 runs multiple LEDs in a forward and backward pattern. The lab report assignment involves creating code to control 5 LEDs with a pushbutton to perform 4 patterns: all on, running LEDs forward, running backward, and all off.

Uploaded by

Abdul Aziz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
81 views5 pages

Lab 1: Digital Input and Output: Task 1: Blinking An Led

The document describes four tasks in an Arduino lab involving digital input and output using LEDs and pushbuttons. Task 1 involves blinking an LED using the Arduino code. Task 2 blinks LEDs using a pushbutton. Task 3 adds multiple blink modes controlled by the pushbutton count. Task 4 runs multiple LEDs in a forward and backward pattern. The lab report assignment involves creating code to control 5 LEDs with a pushbutton to perform 4 patterns: all on, running LEDs forward, running backward, and all off.

Uploaded by

Abdul Aziz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 5

LAB 1: DIGITAL INPUT AND OUTPUT

TASK 1: BLINKING AN LED


SCHEMATICS

ARDUINO CODE
int led = 13; void loop(){
setup() digitalWrite(led, HIGH);
void setup(){ delay(250);
pinMode (led, OUTPUT); digitalWrite(led, LOW);
} delay(250);
}
TASK 2: BLINKING LEDS USING PUSHBUTTON
SCHEMATICS

ARDUINO CODE
int led=13; void loop() {
int pushbutton=3; int a=digitalRead(3);
if(a==1){
void setup() { digitalWrite(13,HIGH);
pinMode(led, OUTPUT); delay(250);
pinMode(pushbutton, INPUT); digitalWrite(13,LOW);
} delay(250);
}
else{
digitalWrite(13,LOW);}
}
TASK 3: BLINKING LEDS USING PUSHBUTTON WITH MULTIPLE MODES
SCHEMATICS

ARDUINO CODE

int led=13; if(count==0)


int pushbutton=3; { digitalWrite(13,HIGH);
int count=0; delay(250);
digitalWrite(13,LOW);
void setup() { delay(250);
pinMode(led, OUTPUT); }
pinMode(pushbutton, INPUT); else if(count==1)
} {digitalWrite(13,HIGH);}
else if(count==2)
void loop() { {digitalWrite(13,LOW);}
int a=digitalRead(3); }
if(a==1)
{ count=count+1;
delay(100);
if(count>3)
count=0;
}
TASK 4: RUNNING MULTIPLE LEDS
SCHEMATICS

ARDUINO CODE

int ledCount = 5; void loop() {


int ledPins[] = { 9, 10, 11, for (int i = 0; i < ledCount-
12, 13 }; 1; i++){
int ledDelay = 300; digitalWrite(ledPins[i],
HIGH);
void setup() { delay(ledDelay);
for (int i = 0; i < ledCount; digitalWrite(ledPins[i], LOW);
i++){ }
pinMode(ledPins[i], OUTPUT); for (int i = ledCount-1; i >
} 0; i--){
} digitalWrite(ledPins[i],
HIGH);
delay(ledDelay);
digitalWrite(ledPins[i], LOW);
}
}
LAB REPORT 1

Write a code using a pushbutton and 5 LEDs to perform 4 types of LED pattern by pressing
the pushbutton which are
1. All ON
2. Running LED forward
3. Running LED backward
4. All OFF

The report need to be submitted during the following week before the class begin.
The report should consist of
1. Introduction
2. Schematics
3. Flowchart
4. Discussion
5. Conclusion
(page1: cover page, names, page2: into and schematics, page3: code flowchart, page 4:
discussion n conclusion)

You might also like