int soilPin1 = A0;
int soilPin2 = A1;
int soilPin3 = A2;
int soilPin4 = A3;
继电器接arduino D7-D10口
int pump1=7; //pump1 at pin 7
int pump2=8; //pump2 at pin 8
int pump3=9; //pump1 at pin 9
int pump4=10; //pump2 at pin 10
关于土壤探头,它的模拟值是0-1023,我设置的临界值是900,这个可以调整的。是aruduino程序里调整参数。小于900需要防水。大于900不需要水。一个是通过调整探头的电位器,把灯调亮。
//this code is written by gada888 in 26-12-2021
int soilPin1 = A0;
int soilPin2 = A1;
int soilPin3 = A2;
int soilPin4 = A3;
int soilReading1;
int soilReading2;
int soilReading3;
int soilReading4;
int pump1=7; //pump1 at pin 7
int pump2=8; //pump2 at pin 8
int pump3=9; //pump1 at pin 9
int pump4=10; //pump2 at pin 10
int tempo=2000; //watering time of 2 seconds
int ledboard=13; //on board led at pin 13
void setup()
{
Serial.begin(9600);
pinMode(pump1,OUTPUT); //pump1 output
pinMode(pump2,OUTPUT); //pump2 output
pinMode(pump3,OUTPUT); //pump3 output
pinMode(pump4,OUTPUT); //pump4 output
pinMode(ledboard,OUTPUT); //on board led output
digitalWrite(ledboard,LOW); //turn off Arduino led