top of page
//*** Code ควบคุมความชื่นในดิน ด้วยเซ็นเซอร์วัดความชื้นในดิน Soil Moisture ***//
int RelayOnPump = 3;
int led1 = 4;
int SoilSensor = A0;
int sensorValue = 0;
void setup()
{
Serial.begin(9600);
pinMode(RelayOnPump, OUTPUT);
pinMode(led1, OUTPUT);
pinMode (SoilSensor, INPUT);
}
void loop()
{
sensorValue = analogRead(A0);
if (sensorValue >=600 && sensorValue <=800)
{
Serial.println(sensorValue);
digitalWrite(RelayOnPump, LOW);
digitalWrite(led1, HIGH);
}
else
{
Serial.println(sensorValue);
digitalWrite(RelayOnPump, HIGH);
digitalWrite(led1, LOW);
}
delay(1000);
}
bottom of page