งานปฏิบัติ 4
Code
int PT1 = 13;
int PT2 = 12;
int BTS1 = 0;
int BTS2 = 0;
void setup() {
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
pinMode(PT1, INPUT);
pinMode(PT2, INPUT);
digitalWrite(3, LOW);
digitalWrite(2, LOW);
}
void loop() {
BTS1 = digitalRead(PT1);
BTS2 = digitalRead(PT2);
if(BTS1 == LOW){
digitalWrite(3, LOW);
digitalWrite(2, HIGH);
delay(500);
}
if(BTS2 == LOW){
digitalWrite(3, HIGH);
digitalWrite(2, LOW);
delay(500);
}
}
ความคิดเห็น
แสดงความคิดเห็น