Data bermanfaat
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
Rabu, 03 Juli 2019
hal1
Paslun
Desain Hardware
alat :
led 1 terhubung ke pin 2
led 2 terhubung ke pin 3
Relay 1 terhubung ke pin 4 ( untuk menggerakkan pintu buka)
Relay 2 terhubung ke pin 5 ( untuk menggerakkan pintu tutup)
Desain tampilan depan Mit App Inventor
Desain tampilan belakang Mit App Inventor (bagian program)
Program arduino
int nilai;
void setup() {
pinMode (2,OUTPUT);
pinMode (3,OUTPUT);
pinMode (4,OUTPUT);
pinMode (5,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 ( nilai ==3 ) digitalWrite( 4, HIGH );
if ( nilai ==4 ) digitalWrite( 5, HIGH );
if ( nilai ==7 ) { digitalWrite( 4, LOW ); digitalWrite( 5, LOW ); }
delay (200);
} }
Kelemahan alat yaitu pintu pagar tidak dapat auto stop.
saran tambah sesor limit switch.
Program kedua
int ls1, ls2, nilai ;
void setup() {
pinMode (12,INPUT);
pinMode (13,INPUT);
pinMode (2,OUTPUT);
pinMode (3,OUTPUT);
pinMode (4,OUTPUT);
pinMode (5,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 (n!= nilai ) { n=nilai ;
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 ( nilai ==3 ) digitalWrite( 4, HIGH ) ;
if ( nilai ==4 ) digitalWrite( 5, HIGH );
if ( nilai ==7 ) { digitalWrite( 4, LOW ); digitalWrite( 5, LOW ); }}
// }
ls1= digitalRead (12);
ls2= digitalRead (13);
if (ls1== HIGH ) {
digitalWrite( 4, LOW );
}
if (ls2== HIGH ) {
digitalWrite( 5, LOW );
}
delay (200);
nilai =0;
}
Sudah ada limit switch tapi masih bisa buka tutup nyala bersama
Desain Hardware
alat :
led 1 terhubung ke pin 2
led 2 terhubung ke pin 3
Relay 1 terhubung ke pin 4 ( untuk menggerakkan pintu buka)
Relay 2 terhubung ke pin 5 ( untuk menggerakkan pintu tutup)
Desain tampilan depan Mit App Inventor
Desain tampilan belakang Mit App Inventor (bagian program)
Program arduino
int nilai;
void setup() {
pinMode (2,OUTPUT);
pinMode (3,OUTPUT);
pinMode (4,OUTPUT);
pinMode (5,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 ( nilai ==3 ) digitalWrite( 4, HIGH );
if ( nilai ==4 ) digitalWrite( 5, HIGH );
if ( nilai ==7 ) { digitalWrite( 4, LOW ); digitalWrite( 5, LOW ); }
delay (200);
} }
Kelemahan alat yaitu pintu pagar tidak dapat auto stop.
saran tambah sesor limit switch.
Program kedua
int ls1, ls2, nilai ;
void setup() {
pinMode (12,INPUT);
pinMode (13,INPUT);
pinMode (2,OUTPUT);
pinMode (3,OUTPUT);
pinMode (4,OUTPUT);
pinMode (5,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 (n!= nilai ) { n=nilai ;
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 ( nilai ==3 ) digitalWrite( 4, HIGH ) ;
if ( nilai ==4 ) digitalWrite( 5, HIGH );
if ( nilai ==7 ) { digitalWrite( 4, LOW ); digitalWrite( 5, LOW ); }}
// }
ls1= digitalRead (12);
ls2= digitalRead (13);
if (ls1== HIGH ) {
digitalWrite( 4, LOW );
}
if (ls2== HIGH ) {
digitalWrite( 5, LOW );
}
delay (200);
nilai =0;
}
Sudah ada limit switch tapi masih bisa buka tutup nyala bersama
Langganan:
Postingan (Atom)