TUGAS PRAKTIKUM-7 “Blink Eksternal”
Nama Kelompok :
1.
Riski Ariyanto / 163600047
2.
Mufti Maulana Rahman / 163600059
a) LED Menyala Terang-Redup
Listing
code
int led=3;
int V1=0;
int V2=5;
void setup(){
pinMode(led,
OUTPUT);
}
void loop(){
analogWrite(led,
V1);
V1=V1+V2;
if(V1==0||V1==255){ //jika V=0 atau V1=225 maka nilai V2=-5
V2=-V2
}
delay(50);
}
Running program
b) Running LED (LED 1-6)
Listing code
int led [ ]={2, 3, 4, 5,
6, 7};
void setup(){
int n;
for(n=0;n<6;n++){
pinMode(led, OUTPUT);
}
}
void loop(){
int n;
int x=100;
for(n=0;n<6;n++){
digitalWrite(led[n], HIGH);
delay(x);
digitalWrite(led[n], LOW);
}
}
Running program
c) Running LED Bolak-balik (LED 1-6, 6-1)
Listing code
int led [ ]={2, 3, 4, 5, 6, 7};
void setup(){
int n;
for(n=0;n<6;n++){
pinMode(led, OUTPUT);
}
}
void loop(){
int n;
int x=100;
for(n=0;n<6;n++){
digitalWrite(led[n], HIGH);
delay(x);
digitalWrite(led[n], LOW);
}
for(n=6;n>0;n--){
digitalWrite(led[n], HIGH);
delay(x);
digitalWrite(led[n], LOW);
}
}
Running program
Running program
Komentar
Posting Komentar