Why can't i pwm the pin 13 led on the arduino giga wifi

when I upload code to the arduino, it wont let me pwm pin 13


int led = 13;       
int brightness = 0;  
int fadeAmount = 5;  

void setup() {
  pinMode(led, OUTPUT);
}

void loop() {
  
  analogWrite(led, brightness);
  brightness = brightness + fadeAmount;
  
  if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount;
  }
  delay(30);
}

Is it just the bare board or do you have anything else attached to it?

just the bare board

From the GIGA datasheet:

The GIGA R1 has 12 PWM capable pins, the PWM capable pins are 2-12.

1 Like

The built-in LED is not on pin 13 and it's actually an RGB LED, but not PWM.

Sadly this is just lacking documentation again, most of the modern microcontrollers including giga r1 support Pwm on all or almost all pins. With giga r1 it will likely be all but pure analog pins. Arduino zero also didn’t say which pins supported Pwm properly.
Some pins on the giga r1 are actually also 5V tolerant though we don’t know which.

1 Like

I'll add something to this thread in case anyone bumps into it:

  • The built-in LED of the GIGA is not attached to pin 13. So the code posted in this thread will have no effect, because it's doing PWM on a pin that is not connected to anything. If you attach a LED to pin 13, the posted code will work :slight_smile:
  • To control the built-in LED, the LED_BUILTIN macro can be used instead of specifying the actual the pin number.
    • Since the LED is RGB, its components are actually connected to three pins which can be called as LEDR, LEDG and LEDB.
    • Also note that since the pins the built-in LED is attached to are not PWM pins, digitalWrite() shall be used.
  • GIGA R1 has 12 PWM pins (it actually has more, but those are the ones that always guaranteed to work while others require more knowledge of the microcontroller internals).
1 Like

Thanks

Thank you for the explanation.
Is there a copy of the factory sketch which blink color cycles the built-in RGB LED?