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

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

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

CODE | Human Body Infrared Detector and Relay Light - Arduino Project 048

CODE | Human Body Infrared Detector and Relay Light - Arduino Project 048

Project 48 Human Body Infrared Detector and Relay LightThis Infrared Human Sensor referenc…

DIY T12 Soldering (Full-Assembled Kits)

DIY T12 Soldering (Full-Assembled Kits)

前两天我们刚做了一起T12焊台的半散件的DIY组装,但是很多小伙伴反应这个版本的不够过瘾,对T12焊台的结构还是一知半解的,所以今天我们在上一期的基础上做一期特别的,全散件T12零件包的DIY组装视频…

CODE | Line Following Robot - Arduino Project 030

CODE | Line Following Robot - Arduino Project 030

Project 30 Line Following RobotA line following robot is an autonomous vehicle that detects and foll…

Electric Maker and Coding Basic Tools and Knowledge

Electric Maker and Coding Basic Tools and Knowledge

电子制作|启程前的入门知识电子制作是一件充满乐趣和成就感的活动,也许在开始时会有一些挑战或者坎坷,慢慢的当你踏入电子制作的世界之后,我相信你肯定再也停不下脚步,本部分电子制作的入门知识将主要围绕:工具…

DIY T12 Soldering (Partial -Assembled Kits)

DIY T12 Soldering (Partial -Assembled Kits)

今天我们要自己动手做一台高性价比的T12焊台,我们通过DIY来体验T12的快速温升带给我们焊接的畅快。T12的焊台有什么让人着迷地方?为什么很多焊接达人,都希望拥有一台高品质的T12焊台,DIY一台T…

CODE | Liquid Crystal Displays-Serial to Display - Arduino Project 037

CODE | Liquid Crystal Displays-Serial to Display - Arduino Project 037

The DS18B20 Temperature Sensor is a digital temperature sensor capable of measuring temperatures wit…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.