Skip to content

Instantly share code, notes, and snippets.

@theinventor
Created July 13, 2014 19:31
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 theinventor/0f3fdae00242d46b90b7 to your computer and use it in GitHub Desktop.
Save theinventor/0f3fdae00242d46b90b7 to your computer and use it in GitHub Desktop.
Our code for the peepeealert.com moisture sensing diaper
int sensorPin = 0;
int ledPin = 1;
int sensorVal = 0;
int counter = 0;
void setup()
{
// strip.begin();
// strip.show(); // Initialize all pixels to 'off'
pinMode(sensorPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
// Serial.begin(9600);
}
void loop()
{
sensorVal = digitalRead(sensorPin);
if (sensorVal == LOW)
{
counter = counter+1;
}
else
{
counter = 0;
}
if (counter > 3)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment