Sie sind auf Seite 1von 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)

Das könnte Ihnen auch gefallen