Beginners‎ > ‎

led blink

This is the first test of your board. The goal is to blink a led.





// test blink with Pinguino

#define PIC18F4550

void setup()

void loop()

Default processor in Pinguino IDE is 18F2550. If 18F4550 is used, the #define 18F4550 directive must be used.
A pinguino program is divided in a setup function, which is executed once at the beginning of the program. The loop function loops consecutively. This is where your program will test and change state of input and output.
In this example, the setup function defines pin 0 type. The pin 0 drives the led, so it is used as an output. The pinMode instruction is used to define pin type. In this case, pinMode(0,OUTPUT); defines pin 0 as an output.
Now we can wire our led on pin 0. The state of a digital pin can be 0 or LOW  ( 0 Volt ) or 1 or HIGH ( 5 Volt ).
Loop function can now execute our program. To blink, the led must be first powered ( 5 Volt ).
Then we must put a delay. Power must be stopped. and another delay.
Because this function loops, the led will blink indefinitely.
Function digitalWrite defines the state of an output. digitalWrite(0,HIGH); will put HIGH ( or 1 ) on output 0, the led is powered.
delay introduces a delay. Time in milliseconds is defined by the parameter. So, delay(500); introduces a 500 mS delay. The led remains powered but nothing happens.
digitalWrite(0,LOW); set output to 0 Volt. The led stops.
Then the same delay of 500 mS stops the program.
When this delay is expired, the processor restarts the loop.


- change delay to see what happen,
- change pin and modify the program to blink the led on another pin.
- put another led on another pin and blink the 2 leds.