int big = 2;
int push = 3;
int datain = 4;
void setup()
{
Serial.begin(9600);
pinMode(big, OUTPUT);
pinMode(push, OUTPUT);
pinMode(datain, OUTPUT);
}
void loop()
{
int num=1;
for (int i = 0; i < 8; i++)
{
Serial.println("kaishi");
digitalWrite(big, LOW);
int data = num;
//data分别为 1 2 4 8 16
//转换为二进制后分别取出每一位的值并写入到寄存器中
for (int j = 0; j < 8; j++)
{
digitalWrite(push, LOW);
digitalWrite(datain, data & 1);
data = data >> 1;
digitalWrite(push, HIGH);
}
digitalWrite(big, HIGH);
num = num<<1;
delay(1000);
}
}