int led[]={2,3,4,5,6,7,8,9};
int i=0,j;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
for(i=0;i<8;i++)
{
pinMode(led[i],OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("LED = ");
for(j=0;j<8;j++)
{
if(j==i) Serial.print("1");
else Serial.print("0");
}
Serial.println();
digitalWrite(led[i],HIGH);delay(1000);
digitalWrite(led[i],LOW);
i++;
if(i>7)
i=0;
}
沒有留言:
張貼留言