Skip to content

Instantly share code, notes, and snippets.

@vivekprm
Forked from neonil123/Arduino uno code
Created October 27, 2018 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vivekprm/298e42f7c198eb1b1a7a97f9512fb577 to your computer and use it in GitHub Desktop.
Save vivekprm/298e42f7c198eb1b1a7a97f9512fb577 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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment