byte x;
byte LED_pin[] = {2,3,4,5,6,7,8,9,10,11 };
void setup()
{
for (x=0; x<=10; x++)
{
pinMode(LED_pin[x], OUTPUT);
}
}
void loop()
{
for (x=0; x<=10; x++)
{
digitalWrite(LED_pin[x],HIGH);
}
delay(1000);
for (x=0; x<=10; x++)
{
digitalWrite(LED_pin[x],LOW);
}
delay(1000);
}
void setup()
{
pinMode(2,OUTPUT);pinMode(3,OUTPUT);pinMode(4,OUTPUT);pinMode(5,OUTPUT);pinMode(6,OUTPUT);
pinMode(7,OUTPUT);pinMode(8,OUTPUT);pinMode(9,OUTPUT);pinMode(10,OUTPUT);pinMode(11,OUTPUT);
}
void loop()
{
digitalWrite(2,LOW);digitalWrite(3,LOW);digitalWrite(4,LOW);digitalWrite(5,LOW);digitalWrite(6,LOW);
digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);
delay(100);
digitalWrite(2,HIGH);digitalWrite(3,LOW);digitalWrite(4,LOW);digitalWrite(5,LOW);digitalWrite(6,LOW);
digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,HIGH);
delay(100);
digitalWrite(2,HIGH);digitalWrite(3,HIGH);digitalWrite(4,LOW);digitalWrite(5,LOW);digitalWrite(6,LOW);
digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,HIGH);digitalWrite(11,HIGH);
delay(100);
digitalWrite(2,LOW);digitalWrite(3,HIGH);digitalWrite(4,HIGH);digitalWrite(5,LOW);digitalWrite(6,LOW);
digitalWrite(7,LOW);digitalWrite(8,LOW);digitalWrite(9,HIGH);digitalWrite(10,HIGH);digitalWrite(11,LOW);
delay(100);
digitalWrite(2,LOW);digitalWrite(3,LOW);digitalWrite(4,HIGH);digitalWrite(5,HIGH);digitalWrite(6,LOW);
digitalWrite(7,LOW);digitalWrite(8,HIGH);digitalWrite(9,HIGH);digitalWrite(10,LOW);digitalWrite(11,LOW);
delay(100);
digitalWrite(2,LOW);digitalWrite(3,LOW);digitalWrite(4,LOW);digitalWrite(5,HIGH);digitalWrite(6,HIGH);
digitalWrite(7,HIGH);digitalWrite(8,HIGH);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);
delay(100);
digitalWrite(2,LOW);digitalWrite(3,LOW);digitalWrite(4,LOW);digitalWrite(5,LOW);digitalWrite(6,HIGH);
digitalWrite(7,HIGH);digitalWrite(8,LOW);digitalWrite(9,LOW);digitalWrite(10,LOW);digitalWrite(11,LOW);
delay(100);
}
char LED_pin[] = {2,3,4,5,6,7,8,9,10,11 };
...
...
void send2port(int data)
{
if (data & 1 ){digitalWrite(LED_pin[0],HIGH);} else {digitalWrite(LED_pin[0],LOW);}
if (data & 2 ){digitalWrite(LED_pin[1],HIGH);} else {digitalWrite(LED_pin[1],LOW);}
if (data & 4 ){digitalWrite(LED_pin[2],HIGH);} else {digitalWrite(LED_pin[2],LOW);}
if (data & 8 ){digitalWrite(LED_pin[3],HIGH);} else {digitalWrite(LED_pin[3],LOW);}
if (data & 16 ){digitalWrite(LED_pin[4],HIGH);} else {digitalWrite(LED_pin[4],LOW);}
if (data & 32 ){digitalWrite(LED_pin[5],HIGH);} else {digitalWrite(LED_pin[5],LOW);}
if (data & 64 ){digitalWrite(LED_pin[6],HIGH);} else {digitalWrite(LED_pin[6],LOW);}
if (data & 128 ){digitalWrite(LED_pin[7],HIGH);} else {digitalWrite(LED_pin[7],LOW);}
if (data & 256 ){digitalWrite(LED_pin[8],HIGH);} else {digitalWrite(LED_pin[8],LOW);}
if (data & 512 ){digitalWrite(LED_pin[9],HIGH);} else {digitalWrite(LED_pin[9],LOW);}
}