Alex, fading a LED can only be done with the DIGITAL (D) input/output pins of port 2 and 3 on the JeeNode.
I was also very confused about the mapping of pins from Adruino to JeeNode, and actually still can't give a direct conversion.
When looking at the Adruino, it can be seen that it had more pins than the JeeNode has, but I guess the RF12 radio takes up these extra pins.
If you use the Ports library, as demonstrated in the other topic, you see that mode and digiWrite can be used for digital pins and mode2 and digiWrite2 for analog pins!
If you don't want to use the Ports library you can use this code for testing the fading LEDS:
Code: Select all
int brightness = 0; // how bright the LED is
int brightness2 = 255; // how bright the LED is
int fadeAmount = 3; // how many points to fade the LED by
void setup() {
// declare pin 9 to be an output:
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
}
void loop() {
// set the brightness of pin 9:
analogWrite(5, brightness);
analogWrite(6, brightness2);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
brightness2 = brightness2 - fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
delay(200);
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(40);
}
I extended the basic code a little to have two opposing fading LEDS connected on JeeNode port 2 and 3 on the D pin!