6 ways to blink a led with a Pinguino

Here are 6 ways to blink the built-in LED on your Pinguino board :

void setup()
{
TRISAbits.TRISA4 = OUTPUT;
}

void loop()
{
LATAbits.LATA4 = LOW;
delay(50);
LATAbits.LATA4 = HIGH;
delay(500);
}
Example 1 : with PIC registers
void setup()
{
pinMode(USERLED, OUTPUT);
}

void loop()
{
digitalWrite(USERLED, LOW);
delay(500);
digitalWrite(USERLED, HIGH);
delay(500);
}
Example 2 : the Arduino way
void setup()
{
pinMode(USERLED, OUTPUT);
}

void loop()
{
toggle(USERLED);
delay(500);
}
Example 3 : even simpler ?
void myBlink() { toggle(USERLED); }

void setup()
{
pinMode(USERLED, OUTPUT);
// Use Timer0 to toggle the USERLED every 500 ms
OnTimer0(myBlink, INT_MILLISEC, 500);
}

void loop()
{
}
Example 4 : using an interrupt
void setup()
{
pinMode(USERLED, OUTPUT);
// Enable Watchdog Timer
// Watchdog is driven by the Internal Oscillator (8MHz)
// Nominal period of Watchdog is 4ms
// Watchdog postscaler is set to 1:32768 by config. bits
// Watchdog timer will overload after 32768*4ms = 135sec = 2.25min
System.watchdog();
}

void loop()
{
System.clearWatchdog(); // clear watchdog timer
// Enter Sleep Mode
System.sleep(); // wait for watchdog timer overload
// Back to Run Mode
toggle(USERLED); // toggle the led
}
Example 5 : using the watchdog
blink.gpde
void setup()
{
pinMode(USERLED, OUTPUT);
}

void loop()
{
toggle(USERLED);
delay(500);
}
Example 6 : using the Pinguino Graphical Language