I have a very simple program that is supposed to change the state of D0 when the voltage on A0 drops below 2v. I have added in a couple of publishes as a rudimentary way of determining what the reading on A0 is but (in my head) oddly returns null.
The device connected to A0 has an output which is normally at 3v. When it receives a signal, its output drops to 1.37v. It is this fall that I want to detect (not measure) and subsequently set D0 to high. In terms of wiring, I have the ground of the third-party device connected to the ground of the Core (the GND next to VIN) and the signal connected to A0.
int analogPin = A0;
int digitalPin = D0;
int iRem2 = 0;
void setup() {
pinMode(digitalPin, OUTPUT);
digitalWrite(digitalPin, LOW);
Particle.publish("Status", "Started...");
}
void loop() {
iRem2 = analogRead(analogPin);
if(iRem2 < 2483) { // Equiv to 2v
Particle.publish("REM 2", iRem2);
digitalWrite(digitalPin, HIGH);
digitalWrite(digitalPin, LOW);
}
else {
Particle.publish("REM 22", iRem2);
}
delay(5000);
}
It must be some small oversight I am making, but can’t for the life of me work out what I have/haven’t done.