int sensorPin = A0; // select the input pin for the soil detector
unsigned int sensorValue = 0; // variable to store the value coming from the soil detector
byte latch = 0; //initial variable
void setup()
{
pinMode(13, OUTPUT);
//Start Serial port
Serial.begin(9600); // start serial for output - for testing
}
void loop()
{
// read the value from the soil detector:
sensorValue = analogRead(sensorPin);
if(sensorValue<400)
{
!latch; // This detects whether the switch changed or not
latch ? LED_Burst() : (/*Just smile and wave*/ ); //conditional statement, compressed IF/ELSE statement
}
void LED_Burst() //outside of LOOP()
{
digitalwrite(13, HIGH);
delay(1000); // 1 second delay
digitalWrite(13, LOW);
return;
}
so is this correct? I do hope so.. sorry just learning the ropes