I am having a problem where a configuration and code which works on the breadboard does not work when transferred to the shield.
Basically I am passing current from a separate 12v circuit through the coil of a relay. Going into the switch side of the is the Photon’s 3.3v output © and the NO terminal is then connected back to D6 on the Photon. When the 12v signal is switched, the relay is closed and the 3.3v is allowed to pass from the output to D6, where it is sensed as a HIGH value and actions triggered.
All of this works fine on the breadboard, but when I plug the Photon into the Shield Shield it will trigger but it will stay triggered even when the current to relay coil is shut off. In other words, even though there is no current flowing to the Photon’s D6 pin, the firmware is still detecting current. I have to then ground D6 to remove the trigger voltage.
What am I doing wrong? Perhaps I’ve hooked it up incorrectly, but I have a 9V wall wart powering the Shield Shied through the terminal connection.
Here’s my code…
int led2 = D7; // Assigns the on board LED to boardLed
int sensor = D6; // Assigns the input pin
void setup() {
pinMode(led2, OUTPUT); // Oon-board LED is output
pinMode(sensor, INPUT_PULLDOWN); // Sensor pin is input
digitalWrite(led2, LOW);
}
void loop() {
while(digitalRead(sensor) == HIGH) {
digitalWrite(led2, HIGH);
RGB.control(true);
RGB.color(255, 0, 0);
Spark.publish("status", "#occupied", 60);
delay(1000);
}
RGB.control(false);
digitalWrite(led2, LOW);
delay(5000);
}