Created
July 17, 2020 15:11
-
-
Save myarduinosale/e00472085da48630bbd6958f925f8e0e to your computer and use it in GitHub Desktop.
M0664_Arduino
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 = 3; | |
int buzzer = 2; | |
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 > 100){ | |
digitalWrite(led, LOW); | |
digitalWrite(buzzer, HIGH); | |
Serial.println("No Water"); | |
} | |
if (val < 100){ | |
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