This is a program I made.
action sequence
1)Green light turns on when power is applied
-
Supply the sol valve by pressing 15 liter in the touch
(when supplying, the green lamp turns off and the red lamp comes on) -
When the liter supply is finished, the green light comes on again.
** 2 types of safety devices -
Water overflow prevention through leak sensor and water level sensor.
Sol valve does not operate even if only one of them is detected.
#include <RTClib.h>
#include <Adafruit_BusIO_Register.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_I2CRegister.h>
#include <Adafruit_SPIDevice.h>
#include <Wire.h>
#include <Arduino.h>
#include <doxygen.h>
#include <NexButton.h>
#include <NexCheckbox.h>
#include <NexConfig.h>
#include <NexCrop.h>
#include <NexDualStateButton.h>
#include <NexGauge.h>
#include <NexGpio.h>
#include <NexHardware.h>
#include <NexHotspot.h>
#include <NexNumber.h>
#include <NexObject.h>
#include <NexPage.h>
#include <NexPicture.h>
#include <NexProgressBar.h>
#include <NexRadio.h>
#include <NexRtc.h>
#include <NexScrolltext.h>
#include <NexSlider.h>
#include <NexText.h>
#include <NexTimer.h>
#include <Nextion.h>
#include <NexTouch.h>
#include <NexUpload.h>
#include <NexVariable.h>
#include <NexWaveform.h>
const int relay = 8;//SOLVALVE
const int led0 = 10;//LAMP GREEN
const int rain = A0;//LEAK SENSOR
const int over = A1;//WATER LEVEL SENSOR
const int led1 = 6;//LAMP RED
NexButton b0 = NexButton(0, 3, "b0");// POWER on switch+
NexButton b11 = NexButton(1, 3, "b11");//POWER OFF
NexButton b21 = NexButton(2, 3, "b21");// 15 L
NexButton b22 = NexButton(2, 4, "b22");// 20 L
NexButton b23 = NexButton(2, 5, "b23");// 30 L
// Register a button object to the touch event list.
NexTouch *nex_listen_list[] = {
&b21,
&b0,
&b11,
&b22,
&b23,
NULL
};
void b0PushCallback(void *ptr) {
digitalWrite(relay, HIGH);
}
void b11PushCallback(void *ptr) {
digitalWrite(relay, LOW);
}
void b21PushCallback(void *ptr) {
digitalWrite(relay, LOW);
digitalWrite(led0, LOW);
delay (15000);//15초간 물공급
digitalWrite(relay, HIGH);
digitalWrite(led0, HIGH);
delay (10);
}
void b22PushCallback(void *ptr) {
digitalWrite(relay, LOW);
digitalWrite(led0, LOW);
delay (20000);//20초간 물공급
digitalWrite(relay, HIGH);
digitalWrite(led0, HIGH);
delay (10);
}
void b23PushCallback(void *ptr) {
digitalWrite(relay, LOW);
digitalWrite(led0, LOW);
delay (25000);//25초간 물공급
digitalWrite(relay, HIGH);
digitalWrite(led0, HIGH);
delay (10);
}
void setup(void) {
// Set LEDs as outputs
pinMode(relay, OUTPUT);
pinMode(led0, OUTPUT);
pinMode(led1, OUTPUT);
Serial.begin(9600);
nexInit();
b0.attachPush(b0PushCallback, &b0);
b21.attachPush(b21PushCallback, &b21);
b22.attachPush(b22PushCallback, &b22);
b23.attachPush(b23PushCallback, &b23);
b11.attachPush(b11PushCallback, &b11);
}
}
void loop(void){
{nexLoop(nex_listen_list);}
}
Serial.println(analogRead(A0));
Serial.println(analogRead(A1));
delay(10);
if(analogRead(A0)<800||(A1)<800){
digitalWrite(10,HIGH);
digitalWrite(8,LOW);
digitalWrite(6,LOW);
delay(100);
digitalWrite(6,HIGH);
delay(100);
}
else{
digitalWrite(10,LOW);
digitalWrite(8,HIGH);
digitalWrite(6,HIGH);
}
}
```[quote="choifamily, post:1, topic:1056248, full:true"]
This is a program I made.
action sequence
1)Green light turns on when power is applied
2) Supply the sol valve by pressing 15 liter in the touch
(when supplying, the green lamp turns off and the red lamp comes on)
3) When the liter supply is finished, the green light comes on again.
** 2 types of safety devices -
Water overflow prevention through leak sensor and water level sensor.
Sol valve does not operate even if only one of them is detected.

