2013/05/16

[Arduino] LED 跑馬燈效果


void setup()
{
  // put your setup code here, to run once:
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
}

void loop()
{
  // put your main code here, to run repeatedly:

  int Cnt = 1;
  int N;

  while(true)
  {
    N = (Cnt % 4) + 2;
    digitalWrite(N,HIGH);
    delay(100);
    digitalWrite(N,LOW);
    delay(100);
    Cnt++;
  }
}