0.7.0-rc firmware. I’m getting strange green light about minute or hour. How do I stop getting green light each time?
Here’s my code.
const int DO_pin = D2;
const int AO_pin = A0;
int sound;
int led1 = D7;
void setup() {
pinMode(DO_pin, INPUT);
pinMode(led1, OUTPUT);
Serial.begin(9600);
}
void loop()
sound = analogRead(AO_pin);
Serial.print(digitalRead(DO_pin));
Serial.print("-");
Serial.println(analogRead(AO_pin));
// Detect Dog Bark.
if (sound > 150) {
digitalWrite(led1, HIGH);
Particle.publish("poop",NULL, 60, PRIVATE);
}
if (sound < 150) {
digitalWrite(led1, LOW);
}
delay (50);
}
IFTTT
A0 is not as input defined in setup.
Are you sure that this code flashed before?
Oh good eyes. I didn’t see it…
pinMode(AO_pin, INPUT);
Thanks.
@ParticleIce, the pinMode()
statement is not required as per the docs:
Since 0.5.3 Note: you do not need to set the pinMode() with analogRead().
There is also a risk that multiple Particle.publish() will be triggered, exceeding the 1-per-second rate limit. You can burst up to 4 in one second but it must be followed by a 4 second pause.
1 Like
@Postler, pinMode()
doesn’t/shouldn’t be set for analogRead()
. The function does some elaborate setting up which would be undone after read and redone before next read. To prevent that don’t set pinMode()
.
If you really want to set the correct pin mode, you’d call pinMode(A0, AN_INPUT)
(which is not documented since it’s done implicitly anyway)
If any new users using this code. You might see strange Green light flash.
Hard Reset. You might see this.
$ particle flash --factory tinker
Opening DFU capable USB device...
ID 1d50:607f
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: Invalid DFU suffix signature
A valid DFU suffix will be required in a future dfu-util release!!!
Last page at 0x00038183 is not writeable
state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 1024
DfuSe interface name: "Internal Flash "
Downloading to address = 0x00020000, size = 98692
Error writing firmware...Invalid DFU suffix signature
A valid DFU suffix will be required in a future dfu-util release!!!
Last page at 0x00038183 is not writeable
Unplug USB and replug it.( Green light ) Press hard reset
particle flash --usb cc3000 (will blink magenta and eventually revert to yellow)
particle flash --usb tinker
now setup wifi credentials using particle serial wifi
Back to normal state.
1 Like