-
-
Save vivekprm/298e42f7c198eb1b1a7a97f9512fb577 to your computer and use it in GitHub Desktop.
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
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment