最新消息:680元/半年,推荐全网最具性价比的一站式编程学习平台码丁实验室

arduino从零开始(18)两个移位寄存器

Arduino 少儿编程 1681浏览 0评论

友情提示:680元/半年,儿童学编程,就上码丁实验室

arduino从零开始(18)两个移位寄存器


你将学到什么?

1、你将学到如何将两个74HC595移位寄存器连接在arduino上

2、你将学到如何使用两个移位寄存器控制两个七段数码管


视频若不清晰,观看1080P高清视频网址为:https://v.qq.com/x/page/y0558fp73w1.html?

文字代码如下:

int DATA = 6;

//数字6号脚,连在移位寄存器的14号针脚上,通过arduino传输数据

int LATCH = 8;

//digital 8 to pin 12 on the 74HC595

int CLOCK = 10;

//digital 10 to pin 11 on the 74HC595 for clock

int number_LSB[]={252,96,218,242,102,182,190,224,254,246,238,62,156,122,158,142};

void setup() {

  // put your setup code here, to run once:

pinMode(LATCH,OUTPUT);

pinMode(CLOCK,OUTPUT);

pinMode(DATA,OUTPUT);

}


void loop() {

  // put your main code here, to run repeatedly:

for(byte i=0;i<16;i++)

{

  digitalWrite(LATCH,LOW);

//准备传输数据

  shiftOut(DATA,CLOCK,LSBFIRST,number_LSB[i]+1);

//开始传输数据,+1让小数点显示

  digitalWrite(LATCH,HIGH);

//数据传输完毕

  delay(500);

  }

}


您必须 登录 才能发表评论!