Hello, I’m new to the Photos and I’m nit sure what I’m doing wrong or if there’s something I just don’t know. I’m running through the new book “Programming the Photon” and about 60 pages in there’s a simple circuit with simple code to perform basic PWM on pin A0. When I wire everything up and run the following code, the LED remains as dark as the recesses of the universe.
int ledPin = A0;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
for(int fadeValue=0;fadeValue<=255;fadeValue++){
analogWrite(ledPin, fadeValue);
delay(30);
}
for(int fadeValue=255;fadeValue>=0;fadeValue--){
analogWrite(ledPin, fadeValue);
delay(30);
}
}
Now, if I change analogWrite to digitalWrite, the LED lights. That makes me think the circuit and the code are correct. But, if I change things back to analogWrite, the void greets me again. Just to make sure, I also tried pin A1 and received the same results. I read on this forum that when using PWM, pinMode(ledPin, OUTPUT); may need to get called each time. I tried that with no results. Is there some setting I’m missing to get PWM working for this simple experiment?
The photon is awesome, by the way. Thanks!