当前位置:首页 > 科学研究 > 电子编程 > 正文内容

Arduino Project 018 - Dual Shift Register 8-Bit Binary Counter

RonWang4个月前 (09-17)电子编程199

In Project 18, you will daisy chain (or cascade) another 74HC595 IC onto the one used in Project 17 to create a dual binary counter. 

The first 595 is wired the same as in Project 15.7 The second 595 has +5V and Ground wires going to the same pins as on the first 595. Then, add a wire from Pin 9 on IC 1 to Pin 14 on IC 2. Add another from Pin 

11 on IC 1 to Pin 11 on IC 2, and Pin 12 on IC 1 to Pin 12 on IC 2. 

The same outputs as on the first 595 going to the first set of LEDs go from the second IC to the second set of LEDs. 

项目 Project 18 Dual 8-Bit Binary Counters

/* Coding Ron Wang
   Sep.17th 2024
   Autaba support for coding hardware
   Project 18 Dual 8-Bit Binary Counters
 */
int latchPin = 8; //Pin connected to Pin 12 of 74HC595 (Latch)
int clockPin = 12; //Pin connected to Pin 11 of 74HC595 (Clock)
int dataPin = 11; //Pin connected to Pin 14 of 74HC595 (Data)
void setup() {
 //set pins to output
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(dataPin, OUTPUT);
}
void loop() {
 for (int i = 0; i < 256; i++) { //count from 0 to 255
 digitalWrite(latchPin, LOW); //set latchPin low to allow data flow
 shiftOut(i);
 shiftOut(255-i);
 //set latchPin to high to lock and send data
 digitalWrite(latchPin, HIGH);
 delay(250 );
 }
}
void shiftOut(byte dataOut) {
 boolean pinState; // Shift out 8 bits LSB first, on rising edge of clock
 digitalWrite(dataPin, LOW); //clear shift register ready for sending data
 digitalWrite(clockPin, LOW);
 for (int i=0; i<=7; i++) { // for each bit in dataOut send out a bit
 digitalWrite(clockPin, LOW); //set clockPin to LOW prior to sending bit
// if value of DataOut and (logical AND) a bitmask are true, set pinState to 1 (HIGH)
 if ( dataOut & (1<<i) ) {
 pinState = HIGH;
 }
 else {
 pinState = LOW;
 }
 //sets dataPin to HIGH or LOW depending on pinState
 digitalWrite(dataPin, pinState);
 digitalWrite(clockPin, HIGH); //send bit out on rising edge of clock
 digitalWrite(dataPin, LOW);
 }
 digitalWrite(clockPin, LOW); //stop shifting
}

Arduino Dual Register 8-Bit Binary Counter Circuit

Arduino Dual Shift Register 8-Bit Binary Counter Schematic

版权声明:本文为原创文章,版权归donstudio所有,欢迎分享本文,转载请保留出处!

本文链接:http://parentscn.com/?id=267

标签: Arduino

相关文章

Arduino Project 002 - LED SOS Morse Code Singal

Arduino Project 002 - LED SOS Morse Code Singal

Arduino 电子编程--灯项目及控制,主要使用Arduino编程控制LED灯,实现基本控制Project 2 LED闪烁S.O.S信号。项目2 Project 2 S.O.S...

 Arduino Project 043 - SD CardTemperature Datalogger

Arduino Project 043 - SD CardTemperature Datalogger

Todady I made a simple Arduino datalogger using SD card and DHT11  relative humidity and t...

Arduino Project 032 - BMP280 Pressure Sensor LCD Display

Arduino Project 032 - BMP280 Pressure Sensor LCD Display

For this project we will use Arduino Uno and BMP280 along with LCD 16x2 display module to display te...

Arduino Project 025 - Servo Control

Arduino Project 025 - Servo Control

You will need to obtain a standard RC servo; any of the small or mid-sized servos will do. Larger se...

Arduino Programming Basic - Bollean

Arduino Programming Basic - Bollean

Arduino 程序基础,介绍Arduino程序的基本组成,第一部分编写了10个例子,关于变量及变量名称,串口监视器,if循环,for循环,while循环等。第二部分介绍了函数,全局变量,局部变量和静...

Arduino Project 010 - Serial Controlled Mood Lamp

Arduino Project 010 - Serial Controlled Mood Lamp

For Project 10, you will revisit the circuit from Project 8 — RGB Mood Lamp, but you’ll now delve in...

评论列表

Jacky
Jacky
2个月前 (12-04)

作者在国外更新的呀,先进的技术,我们一起来学习呀。

Jacky
Jacky
2个月前 (12-04)

二进制是计算机的基础,使用灯来显示,挺有意思的。

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。