USB Example

From Pinguino
Jump to: navigation, search


Example for functions: pinMode digitalWrite USB.available USB.read digitalRead

// test USB Linux Magazine Pinguino
// Jean-Pierre MANDON 2008

int i;
uchar caractere,caractere1;

void setup()
{
for (i=0;i<8;i++)
        {
        pinMode(i,OUTPUT);
        digitalWrite(i,LOW);
        }
}

void loop()
{
if (USB.available())
        {
        caractere=USB.read();
        if (caractere=='W') if (USB.available())
                {
                caractere1=USB.read();
                digitalWrite(caractere1,digitalRead(caractere1)^1);
                }
        }
}