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








Tidak ada komentar:

Posting Komentar