The Photon docs claim that RX and TX can be used as analogWrite pins. (http://docs.particle.io/photon/firmware/#i-o-analogwrite)
To test this, I wired up an LED (330ohm resistor in series, connected to the 3.3V rail). Here’s the sketch I ran:
int led_pin = RX;
void setup() {
pinMode(led_pin, OUTPUT);
pinMode(D7, OUTPUT);
}
void loop() {
analogWrite(led_pin, 255);
digitalWrite(D7, LOW);
delay(1000);
analogWrite(led_pin, 0);
digitalWrite(D7, HIGH);
delay(1000);
}
Rather than blinking on and off in sync with the user led as expected, it seems to randomly switch between working “correctly” and only blinking on briefly (maybe 100-150ms, don’t have a scope to check) on the transitions between high and low. And sometimes it stays on and blinks off briefly on the transitions.
I’ve tried changing the delay from 1000 to 1300, 1500 and 2000. No change.
I tried TX instead of RX. No change.
I tried setting both TX and RX to OUTPUTs in setup() instead of just the pin I was analogWriting to. No change.
I’ve tried it both on direct USB power and a 3.7V lipo cell. No change.
I tried using digitalWrite instead of analog write (with HIGH and LOW) and it worked as expected.
Anybody seeing the same behavior or know what’s going on?