Kamis, 19 September 2019

latihan dasar 1


Latihan dasaaaaar bangeeeetsssss... < Led berkedip >



void setup() {

pinMode(2, OUTPUT); }

void loop() {

digitalWrite( 2, HIGH);

delay(500);

digitalWrite(2, LOW);

delay(500);

}


Latihan dasaaaaar kedua lampu berjalan
void setup() {


pinMode(2,OUTPUT); pinMode(3,OUTPUT);


pinMode(4,OUTPUT); pinMode(5,OUTPUT);

}

void loop() {


for (int x = 2 ; x <= 5 ; x =x+1 ) {


digitalWrite ( x, HIGH ); delay (200);


}


delay (300);


for (int y = 2 ; y <= 5 ; y ++ ) {


digitalWrite ( y, LOW );


}


delay (300);


}





Latihan dasaaaaar pengoperasian lampu

const int s1 =13 ,s2 = 12 , led = 2;

void setup() {

pinMode(led, OUTPUT);

pinMode(s1, INPUT);

pinMode(s2, INPUT);

}
void loop() {

byte switch1 = digitalRead (s1) ;

byte switch2 = digitalRead (s2) ;

if (switch1 == HIGH ) digitalWrite (led,HIGH);

if (switch2 == HIGH ) digitalWrite (led,LOW);

delay (100);

}





latihan lain kunjungi link ini  https://datalatihan.blogspot.com/2019/08/halaman1.html

Tidak ada komentar:

Posting Komentar