Created
July 21, 2020 13:04
-
-
Save myarduinosale/4e42eb93dbee3556655a5bcbce7964f3 to your computer and use it in GitHub Desktop.
M0664_ESP8266
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 = A0; | |
int led = 5; | |
int buzzer = 16; | |
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 < 50){ | |
digitalWrite(led, LOW); | |
digitalWrite(buzzer, HIGH); | |
Serial.println("No Water"); | |
} | |
if (val > 50){ | |
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