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

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

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

Resolving the Need to Enter FTP Credentials for WordPress Themes and Plugins

Resolving the Need to Enter FTP Credentials for WordPress Themes and Plugins

解决安装WordPress主题及插件需要输入FTP问题安装一个WordPress好像挺简单,但是默认主题不喜欢,想更换一个,无奈本地可以更换,但是服务器更换的时候需要设置FTP 。OK,设置呗,好像我…

CODE | Keypad 4X4 or 4X3 - Arduino Project 035

CODE | Keypad 4X4 or 4X3 - Arduino Project 035

Most of the time we are used key, button, or switch to get input value in our projects. When we inte…

CODE | Simple Motor Control - Arduino Project 015

CODE | Simple Motor Control - Arduino Project 015

First, you’re going to simply control the speed of a DC motor in one direction, using a power transi…

CODE | Ultrasonic Distance Alarm - Arduino Project 040

CODE | Ultrasonic Distance Alarm - Arduino Project 040

The sensor consists of two primary components: a transmitter and a receiver . The transmitter is res…

CODE | RFID Servo and LED Control System - Arduino Project 045

CODE | RFID Servo and LED Control System - Arduino Project 045

Arduino Programming Basic -- RFID Servo and LED Control System Integrating RFID technology…

TurboC install and debug runtime Environment

TurboC install and debug runtime Environment

C语言调试运行环境TurboC的 上大学时学习《C语言程序设计》(第二版)作者谭浩强,大部分编程时间是在学校机房度过,每次点开桌面的TurboC图标,就开始在里面敲代码,然后保存程序Abc.…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.