Modul 3 perc 1




Percobaan UART






3. Flowchart [kembali] 


Master 

Slave 






//MASTER


#define button 2

bool state,lastState;

void setup(){
  pinMode(button,INPUT);
  Serial.begin(9600);
  lastState= digitalRead(button);
}
void loop(){
  state = digitalRead (button);
  if (state!= laststate){
    lastState= state;
    Serial.write (state ? 'A' : 'B');
  }
  Serial.println(state);
  delay(10);
}


//SLAVE


#define led 2

vooid setup(){
  pinMode (led,OUTPUT);
  Serial.begin(9600);
}
void loop(){
  if (Serial.available() >0){
    char c = Serial.read ();
    if (c== 'A'){
      digitalWrite(led,LOW);
    }else if(c == 'B'){
      digitalWrite(led,HIGH):
    }
  }
}








6. Link Download [kembali] 
Download Video disini
Download Listing Program  disini
Download HTML disini 

Tidak ada komentar:

Posting Komentar