Yes, it's PWM. From my basic knowledge, arduino lets you set the duty cycle in intervals from 0-255. At least that's what it seems like. Here's the original code I chopped up.
/*
Fade
This example shows how to fade an LED on pin 9 up
while fading a 2nd LED on pin 10 down
using the analogWrite() function.
*/
int RedBrightness = 0; // how bright the red LED is
int YellowBrightness = 255; // how bright the yellow LED is
int fadeAmount = 5; // how many points to fade the LED by
void setup() {
// declare pins 9, 10, to be outputs:
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
// set the brightness of pin 9:
analogWrite(9, RedBrightness);
// set the brightness of pin 10:
analogWrite(10, YellowBrightness);
// change the brightness for next time through the loop:
RedBrightness = RedBrightness + fadeAmount;
YellowBrightness = YellowBrightness - fadeAmount;
// reverse the direction of the fading at the ends of the fade:
// and blink the internal LED on pin 13 at the fade end point
if (RedBrightness == 0 || RedBrightness == 255) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}