-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb08702
commit 0193b36
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Description: Read the ADC value measured by the Watering Unit, and the water pump can be switched on and off through the middle button. | ||
*/ | ||
|
||
|
||
#include <M5Stack.h> | ||
|
||
#define INPUT_PIN 36 | ||
#define PUMP_PIN 26 | ||
|
||
bool flag = true; | ||
int rawADC; | ||
|
||
void setup() { | ||
M5.begin(); | ||
M5.Lcd.setTextColor(GREEN); | ||
M5.Lcd.setTextSize(3); | ||
M5.Lcd.setTextDatum(TC_DATUM); | ||
M5.Lcd.drawString("Watering TEST", 160, 20, 1); | ||
M5.Lcd.drawString("ON/OFF PUMP", 160, 200, 1); | ||
pinMode(INPUT_PIN,INPUT); | ||
pinMode(PUMP_PIN,OUTPUT); | ||
pinMode(25,OUTPUT); | ||
digitalWrite(25,0); | ||
} | ||
|
||
char info[30]; | ||
|
||
void loop() { | ||
rawADC = analogRead(INPUT_PIN); | ||
M5.lcd.fillRect(80, 100, 240, 50, BLACK); | ||
M5.Lcd.setCursor(80, 100); | ||
M5.Lcd.print("ADC: "+ String(rawADC)); | ||
Serial.print("Watering ADC value: "); | ||
Serial.println(rawADC); | ||
if(M5.BtnB.wasPressed()){ | ||
digitalWrite(PUMP_PIN,flag); | ||
flag = !flag; | ||
} | ||
M5.update(); | ||
delay(100); | ||
} |