Created
July 13, 2014 19:31
-
-
Save theinventor/0f3fdae00242d46b90b7 to your computer and use it in GitHub Desktop.
Our code for the peepeealert.com moisture sensing diaper
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
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