/* Rain Sensor with Roof Close * ----------- * * Detects when the sensor is tilted, and closes the roof, then exits. * * * @author: Josh Smith, Daniel Zhang, Chang-Yong Boo * */ int motorPin = 11; int inPin = 7; int value = 0; int test = 0; void setup() { pinMode(motorPin, OUTPUT); // initializes digital pin 13 as output pinMode(inPin, INPUT); // initializes digital pin 7 as input } void loop() { value = digitalRead(inPin); // reads the value at a digital input if (value == HIGH && test == 0) { digitalWrite(lmotorPin, HIGH); // turn motor on to close roof delay(1000); digitalWrite(motorPin, LOW); // turn motor off test = 1; //exit function } }