Hi
I’m setting up a magnetic door sensor, and I want my spark to publish the status of the door each second. I have one wire of the sensor in D1, set to HIGH, and the second wire in D6. Every second the spark publishes the status of D6 (high or low). However, when I read the event, the output doesn’t change if I close or open the circuit. Here’s the code:
int sensorIn = D6;
int sensorOut = D0;
void setup() {
pinMode(sensorIn, INPUT);
pinMode(sensorOut, OUTPUT);
digitalWrite(sensorOut, HIGH);
}
void loop() {
if (digitalRead(sensorIn) == HIGH) {
Spark.publish("status","high");
} else {
Spark.publish("status", "low");
}
delay(1000);
}
Can anyone see what’s going wrong? If I change D6 to D7, the blue led turns on when I connect the circuit so I know it’s not a problem with the door sensor.
Thanks