【外设】74HC595移位寄存器-Arduino中文社区 - Powered by Discuz! Archiver

jiayouxiaoniu 发表于 2016-8-24 20:31

【外设】74HC595移位寄存器

一、管脚图:
http://www.arduino.cn/forum.php?mod=image&aid=22075&size=300x300&key=79334414bd5a6aa4&nocache=yes&type=fixnonehttp://www.arduino.cn/forum.php?mod=image&aid=22076&size=300x300&key=02f10a04e09803bd&nocache=yes&type=fixnone

二、真值表:
http://www.arduino.cn/forum.php?mod=image&aid=22077&size=300x300&key=4556e882718e4a58&nocache=yes&type=fixnone

三、电路图
http://www.arduino.cn/forum.php?mod=image&aid=22078&size=300x300&key=7d96aade418e0d15&nocache=yes&type=fixnone



放大的图:

jiayouxiaoniu 发表于 2016-8-24 20:34

附上代码:

/*define pin*/
#define SCLR_PIN 2
#define SI_PIN 3
#define SCK_PIN 4
#define RCK_PIN 5
#define OE_PIN 6

/*define the map of value 0-9*/
#define NUM_VAL 11
int val= {
0xDE,//0
0x06,//1
0xEC,//2
0xAE,//3
0x36,//4
0xBA,//5
0xFA,//6
0x0E,//7
0xFE,//8
0xBE,//9
0x01,//dot
};

/*define the function of display val*/
void disVal(int val);

void setup() {
// put your setup code here, to run once:
pinMode(SCLR_PIN, OUTPUT);
pinMode(SI_PIN, OUTPUT);
pinMode(SCK_PIN, OUTPUT);
pinMode(RCK_PIN, OUTPUT);
pinMode(OE_PIN, OUTPUT);

return;
}

void loop() {
digitalWrite(OE_PIN, LOW);

// put your main code here, to run repeatedly:
for(int i = 0; i < NUM_VAL; i++ )
{
      disVal(val);
      //disVal(0xDE);
      delay(1000);
}

return;
}

void disVal(int val)
{
//set RCK to Low
digitalWrite(RCK_PIN, LOW);

//clear SHIFT Story
digitalWrite(SCLR_PIN, LOW);
digitalWrite(SCLR_PIN, HIGH);

//set the val to SHIFT Story
shiftOut(SI_PIN, SCK_PIN, MSBFIRST, val);

//set RCK to HIGH
digitalWrite(RCK_PIN, HIGH);
return;
}
页: [1]
查看完整版本: 【外设】74HC595移位寄存器