Paso 2: Arduino
si (Serial.available() < = 0) Serial.println ("puerta cerrada");
// **************************************************************************************************
para uso con simpleTweet_01_python.py
const int magReed_pin = 10; número de PIN
int magReed_val = 0;
int currentDoorState = 1; comenzar con circuito abierto
int previousDoorState = 1;
void setup() {}
Serial.Begin(9600);
pinMode (magReed_pin, entrada);
}
void loop() {}
watchTheDoor();
}
void watchTheDoor() {}
magReed_val = digitalRead(magReed_pin);
Si (magReed_val == LOW) {/ / open
currentDoorState = 1;
Si (previousDoorState! = currentDoorState) {}
Si (Serial.available() < = 0) Serial.println ("puerta abierta");
}
}
Si (magReed_val == HIGH) {/ / cerrado
currentDoorState = 2;
Si (previousDoorState! = currentDoorState) {}
Si (Serial.available() < = 0) Serial.println ("puerta cerrada");
}
}
previousDoorState = currentDoorState;
Delay(300);
}
// **************************************************************************************************