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

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

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

STEM|60个好玩的 APP推荐

STEM|60个好玩的 APP推荐

STEAM教育理念最早是美国政府提出的教育倡议,为加强美国K12(中小学)关于科学、技术、工程、艺术以及数学的教育。STEAM的原身是STEM理念,即科学(Science)、技术(Technology…

CODE | Piezo Sounder Melody Player - Arduino Project 012

CODE | Piezo Sounder Melody Player - Arduino Project 012

Rather than using the piezo to make annoying alarm sounds, why not use it to play a melody? You are…

CODE | Variables - Arduino Programming Basic

CODE | Variables - Arduino Programming Basic

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

CODE | 4 Digital 7 Segment Display - Arduino Project 033

CODE | 4 Digital 7 Segment Display - Arduino Project 033

Showing Heep and number 0-9 on a Common Anode 7-segment LED display. Displays the numbers 0-9 on the…

About microcontroller board Arduino

About microcontroller board Arduino

What is Arduino?Update time: Jan.1.2023Arduino designs, manufactures, and supports electronic device…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.