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

RonWang2 years ago (2023-10-17)电子编程 COD10

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

Share with Friends:

Related Articles

Identifying Color-Band Resistors and Reading Their Values

Identifying Color-Band Resistors and Reading Their Values

色环电阻的识别与数值读取色环电阻是在电阻封装上(即电阻表面)涂上一定颜色的色环,来代表这个电阻的阻值。色环实际上是早期为了帮助人们分辨不同阻值而设定的标准。色环电阻应用还是很广泛的,如家用电器、电子仪…

CODE | Arduino UNO MP3 Player

CODE | Arduino UNO MP3 Player

Arduino UNO Mp3音乐播放代码今天我们将使用Arduino UNO 和SD卡制作音乐播放器。这个播放器不需要添加多余的模块,只需要SD读卡器和Arduino UNO开发板就可以播放音频文件…

CODE | Basic Stepper Control (Bipolar) - Serial to Display - Arduino Project 028A

CODE | Basic Stepper Control (Bipolar) - Serial to Display - Arduino Project 028A

In this very simple project, you will connect up a stepper motor and then get the Arduino to control…

C04 | Compilation and Execution of Programs

C04 | Compilation and Execution of Programs

C语言教程04:程序的编译与运行源程序也称源代码,是指未编译的、按照一定的程序设计语言规范书写的文本文件,是一系列人类可读的计算机语言指令,可以用汇编语言或高级语言编写。计算机源代码的最终目的是将人类…

How to Understand and Select the Right Wire Specifications

How to Understand and Select the Right Wire Specifications

如何读懂和选用合适的电线的规格?初级电线标准和规格入门知识American Wire Gauge “AWG” Chart – Wire Size & Ampacity TableAmerica…

CODE | Shift Register 8-Bit Binary Counter - Arduino Project 017

CODE | Shift Register 8-Bit Binary Counter - Arduino Project 017

In this project, you’re going to use additional ICs (Integrated Circuits) in the form of shift regis…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.