Created
June 7, 2018 06:36
-
-
Save neonil123/aee7b2ca3704def713a00d8157d25b1d to your computer and use it in GitHub Desktop.
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
const int VAL_PROBE = 0; //Analog pin 0 | |
const int MOISTURE_LEVEL = 450; // the value after the LED goes on | |
void setup() | |
{ | |
Serial.begin(9600); | |
pinMode(13, OUTPUT); | |
pinMode(7, OUTPUT); | |
} | |
void LedState(int state) | |
{ | |
digitalWrite(7,state); | |
} | |
void loop() | |
{ | |
int moisture = analogRead(VAL_PROBE); | |
Serial.print("Moisture = "); | |
Serial.println(moisture); | |
if(moisture > MOISTURE_LEVEL) | |
{ | |
LedState(HIGH); | |
digitalWrite(13,LOW); | |
} | |
else | |
{ | |
LedState(LOW); | |
digitalWrite(13,HIGH); | |
} | |
delay(500); | |
} |
Author
neonil123
commented
Jun 7, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment