Created
July 14, 2020 14:44
-
-
Save myarduinosale/2454978b60b4b9cfb7dce688ab7b3260 to your computer and use it in GitHub Desktop.
M0551_ESP32
This file contains hidden or 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
int sensor = 34; | |
int led = 22; | |
//int buzzer = 23; | |
int val = 0; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(sensor, INPUT); | |
pinMode(led, OUTPUT); | |
//pinMode(buzzer, OUTPUT); | |
} | |
void loop() { | |
val = analogRead(sensor); | |
Serial.println(val); | |
if (val > 500){ | |
digitalWrite(led, LOW); | |
//digitalWrite(buzzer, HIGH); | |
Serial.println("No Water"); | |
} | |
if (val < 500){ | |
digitalWrite(led, HIGH); | |
//digitalWrite(buzzer, LOW); | |
Serial.println("Detected Water"); | |
} | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment