感謝大大幫忙
但是小弟是剛接觸,還是有點看不懂 , 下面是我的程式.想要請問要如何改進去呢
我是要取代最後一個判斷式中的delay
請問要如何修改..
感謝
int pin = 10;
int ledPin1 = 11;
int ledPin2 = 12;
int valve = 14;
int photocellPin = 2;
int photocellPin1 = 3;
int val1 = 0;
int val2 = 0;
void setup() {
pinMode(pin, OUTPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(valve, OUTPUT);
}
void loop() {
val1 = digitalRead(photocellPin);
if(val1==HIGH){
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
}
else{
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
}
val2 = digitalRead(photocellPin1);
if(val2==HIGH){
digitalWrite(pin, HIGH);
}
else{
digitalWrite(pin, LOW);
}
if(val1== HIGH || val2==LOW){
delay(5000);
digitalWrite(valve, HIGH);
}
}
|