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
Minggu, 15 September 2019
hal 2
data cadangan
program dengan tambahan limit switch
int nilai;
void setup() {
pinMode (13,INPUT);
pinMode (12,INPUT);
pinMode (11,INPUT);
pinMode (10,INPUT);
pinMode (2,OUTPUT);
pinMode (3,OUTPUT);
Serial.begin(9600);}
// the loop function runs over and over again forever
void loop() {
if( Serial.available() >0 ) {
nilai = Serial.read(); // Membaca nilai blutut
if ( nilai ==1 ) digitalWrite( 2, HIGH );
if ( nilai ==2 ) digitalWrite( 2, LOW );
if ( nilai ==5 ) digitalWrite( 3, HIGH );
if ( nilai ==6 ) digitalWrite( 3, LOW ); }
if (digitalRead (13) == HIGH) digitalWrite( 2, HIGH );
if (digitalRead (12) == HIGH) digitalWrite( 2, LOW );
if (digitalRead (11) == HIGH) digitalWrite( 3, HIGH );
if (digitalRead (10) == HIGH) digitalWrite( 3, LOW );
delay (100) ;
}
modul relay 4 chanel
program dengan tambahan limit switch
int nilai;
void setup() {
pinMode (13,INPUT);
pinMode (12,INPUT);
pinMode (11,INPUT);
pinMode (10,INPUT);
pinMode (2,OUTPUT);
pinMode (3,OUTPUT);
Serial.begin(9600);}
// the loop function runs over and over again forever
void loop() {
if( Serial.available() >0 ) {
nilai = Serial.read(); // Membaca nilai blutut
if ( nilai ==1 ) digitalWrite( 2, HIGH );
if ( nilai ==2 ) digitalWrite( 2, LOW );
if ( nilai ==5 ) digitalWrite( 3, HIGH );
if ( nilai ==6 ) digitalWrite( 3, LOW ); }
if (digitalRead (13) == HIGH) digitalWrite( 2, HIGH );
if (digitalRead (12) == HIGH) digitalWrite( 2, LOW );
if (digitalRead (11) == HIGH) digitalWrite( 3, HIGH );
if (digitalRead (10) == HIGH) digitalWrite( 3, LOW );
delay (100) ;
}
modul relay 4 chanel
Langganan:
Postingan (Atom)