الكود
void setup() {
pinMode(A0, INPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
int vm = analogRead(A0);
float tm = (vm / 1024.0) * 500.0;
if (tm < 25) {
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
}
else if (25 < tm && tm < 37) {
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
}
else if ( 37 < tm && tm < 100 ) {
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
}
delay(1);
}
No comments:
Post a Comment