K2000

This example will help you to build multi-led programs.

WHAT DO YOU NEED



SCHEMATIC



BOARD



SOFTWARE


// simple multi-led output with Pinguino

void setup()
{
pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
}

void loop()
{
digitalWrite(0,HIGH);
delay(250);
digitalWrite(0,LOW);
digitalWrite(1,HIGH);
delay(250);
digitalWrite(1,LOW);
digitalWrite(2,HIGH);
delay(250);
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
delay(250);
digitalWrite(3,LOW);
}

This is the simplest way to make this board work. The syntax is almost the same one as in the led blink example.
There is more instructions but result is a great K2000 animation !!
We will see now how to reduce the code length.

// optimized multi-led output with Pinguino

int pin;

void setup()
{
for (pin=0;pin<4;pin++) pinMode(pin,OUTPUT);                    
}

void loop()
{
for (pin=0;pin<4;pin++)
    {
    if (pin==0) digitalWrite(3,LOW);
    else
digitalWrite(pin-1,LOW);
    digitalWrite(pin,HIGH);
    delay(250);
    }

Pin is defined as an integer variable. in the setup loop, it is used in a for loop to take values from 0 to 3 and initializing corresponding pinguino pins.
In the main loop, pin takes values from 0 to 3 to power the corresponding pinguino pin and reset the preceding one.
Note the special case, when pin==0, the preceding pin is not -1 but 3.

Comments