In the Pinouts section of the tutorial, it states that pin #4 can be used for PWM, and I'd like this to be the case so I can utilize all 3 PWM pins.
I'm using the following code, ripped from the Trinket tutorial.
Code: Select all
int led = 4;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
for (int i=0; i<256; i++) {
analogWrite(led, i); // PWM the LED from 0 to 255 (max)
delay(5);
}
for (int i=255; i>=0; i--) {
analogWrite(led, i); // PWM the LED from 255 (max) to 0
delay(5);
}
}
I've tried leaving the LED disconnected until after uploading, and only using an external power supply to try and get it working, but I'm having no luck so far.
Am I doing something wrong, or does something else need to be tweaked here? Thanks!