Skip to content

Instantly share code, notes, and snippets.

@neonil123
Created June 7, 2018 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save neonil123/aee7b2ca3704def713a00d8157d25b1d to your computer and use it in GitHub Desktop.
Save neonil123/aee7b2ca3704def713a00d8157d25b1d to your computer and use it in GitHub Desktop.
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);
}
@neonil123
Copy link
Author

untitled sketch_bb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment