#define LED1 21
#define LED2 19
#define LED3 18
#define LED4 5
void send2port(char data);
void setup()
{
pinMode(LED1,OUTPUT);
pinMode(LED2,OUTPUT);
pinMode(LED3,OUTPUT);
pinMode(LED4,OUTPUT);
}
void loop()
{
send2port(0b0000);
delay(200);
send2port(0b1111);
delay(200);
}
void send2port(char data)
{
digitalWrite(LED1,data & 1 ? 1:0);
digitalWrite(LED2,data & 2 ? 1:0);
digitalWrite(LED3,data & 4 ? 1:0);
digitalWrite(LED4,data & 8 ? 1:0);
}
#define LED1 32
#define LED2 33
#define LED3 25
#define LED4 26
#define LED5 27
#define LED6 14
#define LED7 12
#define LED8 13
void send2port(char data);
char pattern[]={0b00000000,
0b00000001,
0b00000011,
0b00000111,
0b00001111,
0b00011110,
0b00111100,
0b01111000,
0b11110000,
0b11100000,
0b11000000,
0b10000000,
0b00000000,
0b11111111,
0b00000000,
0b11111111,
0b00000000,
0b11111111,
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00111100,
0b01111110,
0b11111111,
0b01111110,
0b00111100,
0b00011000};
void setup()
{
Serial.begin(115200);
pinMode(LED1,OUTPUT);
pinMode(LED2,OUTPUT);
pinMode(LED3,OUTPUT);
pinMode(LED4,OUTPUT);
pinMode(LED5,OUTPUT);
pinMode(LED6,OUTPUT);
pinMode(LED7,OUTPUT);
pinMode(LED8,OUTPUT);
delay(50);
}
void loop()
{
char i;
for(i=0;i<(sizeof(pattern)/sizeof(char));i++)
{
send2port(pattern[i]);
Serial.println(pattern[i],DEC);
delay(500);
}
for(i=0;i<(sizeof(pattern)/sizeof(char));i++)
{
send2port(pattern[i]);
Serial.println(pattern[i],DEC);
delay(200);
}
for(i=0;i<(sizeof(pattern)/sizeof(char));i++)
{
send2port(pattern[i]);
Serial.println(pattern[i],DEC);
delay(100);
}
for(i=0;i<(sizeof(pattern)/sizeof(char));i++)
{
send2port(pattern[i]);
Serial.println(pattern[i],DEC);
delay(50);
}
}
void send2port(char data)
{
digitalWrite(LED1,data & 1 ? 1:0);
digitalWrite(LED2,data & 2 ? 1:0);
digitalWrite(LED3,data & 4 ? 1:0);
digitalWrite(LED4,data & 8 ? 1:0);
digitalWrite(LED5,data & 16 ? 1:0);
digitalWrite(LED6,data & 32 ? 1:0);
digitalWrite(LED7,data & 64 ? 1:0);
digitalWrite(LED8,data & 128 ? 1:0);
}