Arduino 74HC595 extended IO

1.7 4HC595 introduction

insert image description here

1. Pin

insert image description here
VCC and GND are the power supply pins of the chip, and the working voltage is 5V.

The 8 pins Q0~Q7 are the output pins of the chip.

The DS pin is a serial input pin. We need to write data to this pin bit by bit.

The STCP pin is a latch pin. When all the 8-bit data of the shift register have been transmitted, the data is copied to the latch by controlling this pin for parallel output.

The SHCP pin is a clock pin. Write data into the shift register by controlling this pin.

The OE pin is output enable. Its function is to control whether the data in the latch is finally output to the Q0-Q7 output pins. It is output at low level and not output at high level. In this experiment, it is directly connected to GND to keep it at low level to output data.

MR is a pin used to reset internal registers. Reset internal registers when low. In this experiment, the direct connection is always kept high on VCC.

The Q7S pin is a serial output pin, which is specially used for chip cascading.
According to the 74HC595 pin description, there are three important pins: data pin (data), latch pin (latch), and clock pin (clock).

2.7 4 HC595 Operation Steps Operation Instructions

latch = LOW Only when it is low, data can be input.
Data can be used to transmit the first bit of data, HIGH/LOW
clock = HIGH data latch
clock = LOW to prepare for the next
data... continue the above steps until the transmission is completed
clock = HIGH to store all Data
clock = LOW prohibits data from being transmitted again
latch = HIGH sends data in parallel

2. Wiring

The negative poles of the 8 LED light-emitting diodes are connected to the development board GND, the positive poles are respectively connected to 220Ω current limiting resistors, and the other ends of the resistors are respectively connected to the Q0~Q7 output pins of the 74HC595 chip.

The VCC and MR pins of 74HC595 are connected to the 5V of the development board, and the OE and GND pins are connected to the GND of the development board. The three control pins DS, SHCP, and STCP are respectively connected to digital pins 8, 9, and 10 of the development board.
q0-q7 are respectively connected to the positive pole of the small lamp
insert image description here

3. Water lamp

/*
   Shift
   74HC595扩展IO,串行驱动8路LED灯
*/
int latchPin = 10;//锁存引脚
int clockPin = 9; //时钟引脚
int dataPin = 8; //数据引脚

void setup ()
{
    
    
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT); //让三个脚都是输出状态
}
void loop()
{
    
    
  for (int data = 0; data < 255; data++)
  {
    
    
    digitalWrite(latchPin, LOW); //将ST_CP口上加低电平让芯片准备好接收数据
    shiftOut(dataPin, clockPin, LSBFIRST, data);
    digitalWrite(latchPin, HIGH); //将ST_CP这个针脚恢复到高电平
    delay(1000); //暂停1秒钟观看显示效果
  }
}

Guess you like

Origin blog.csdn.net/qq_62975494/article/details/131175861