First Example
From Pinguino-Wiki
Example for functions: pinMode digitalWrite delay toggle
Cycles a LED connected to pin 0 with a 1 second cycle - 500 ms on and 500 ms off.
Pinguino programs have to have at least the setup function, which is run once when the board is powered up or after a reset, and the loop function, which, you guessed it, loops forever and is run after the setup function exite
// first test with Pinguino void setup(void) { pinMode(0,OUTPUT); //Set pin 0 as an output } void loop(void) { digitalWrite(0,HIGH); // Turn LED on delay(500); // Wait for 500 milliseconds digitalWrite(0,LOW); // Turn LED off delay(500); }
This can be simplified making use of the Pinguino's toggle function - and itmakes code shorter and more readable:
// second test with Pinguino void setup(void) { pinMode(0,OUTPUT); //Set pin 0 as an output digitalWrite(0,LOW); // Turn LED off } void loop(void) { delay(500); // Wait for 500 milliseconds toggle(0); // Toggle the LEDs state }

