~~NOCACHE~~ ====== lamaPLC: CJMCU-164; SN74HC164D 8-bit Shift Register Module ====== {{ :sensor:cjmcu-164.png?120|CJMCU-164; SN74HC164D 8-bit Shift Register Module}} The CJMCU164 8-bit shift register board is based on the SN74HC164D IC. The SN74HC164D is an 8-bit serial-in parallel-out shift register. **SN74HC164D** These 8-bit shift registers have AND-gated serial inputs and an asynchronous clear (CLR). The serial inputs (A and B) can be controlled completely; a low level at either input prevents new data from entering and resets the first flip-flop to low at the next clock pulse (CLK). When an input is high, it allows the other to control the first flip-flop's state. Data at the serial inputs can be altered while CLK is high or low, provided the minimum setup time is met. Clocking happens on the low-to-high transition of CLK. {{page>:tarhal}} {{ :sensor:cjmcu-164_5.png?400 |}} **Technical data** * Supply voltage range, Vcc: –0.5 V .. 7 V * Input clamp current, IiK (Vi < 0 or Vi > Vcc): ±20 mA * Output clamp current, IoK (Vo < 0 or Vo > Vcc): ±20 mA * Continuous output current, Io (VO = 0 to Vcc): ±25 mA * Continuous current through Vcc or GND: ±50 mA |{{ :sensor:cjmcu-164_2.png?400 |}}|{{ :sensor:cjmcu-164_3.png?400 |}}| ==== CJMCU-164 Pinout ==== {{ :sensor:cjmcu-164.png?200|CJMCU-164; SN74HC164D 8-bit Shift Register Module}} ^Pin Name^Type^Description| ^VCC|Power|Supply voltage (2V to 6V)| ^GND|Power|Ground| ^DSA (A)|Input|Serial Data Input A. AND-gated with DSB| ^DSB (B)|Input|Serial Data Input B. AND-gated with DSA| ^CP / CLK|Input|Clock Input. Shifts data on the low-to-high transition| ^MR / CLR|Input|Master Reset (Active LOW). Clears all outputs to LOW regardless of other inputs| ^Q0 – Q7|Output|8-bit Parallel Data Outputs| **Pin Functions & Usage** * **Gated Serial Inputs (DSA/DSB):** These two pins are logically AND-gated. To use a single data line from your Arduino, connect one of these pins to 5V and send your data to the other, or simply tie both together. * **No Latch Pin:** Unlike the common 74HC595, the '164 lacks a storage/latch register. Data shifted into the register is immediately visible on the output pins (Q0–Q7) as it moves through the register. * **Daisy Chaining:** You can connect multiple CJMCU-164 modules by linking the Q7 output of the first module to a serial input (DSA or DSB) of the next ==== Arduino example code ==== **Arduino Pinout** ^CJMCU-164 Pin^Arduino Pin^Description| ^VCC|5V|Power Supply (2V to 6V)| ^GND|GND|Ground| ^DSA / DSB|Pin 2|Data Input (Connect one or both together)| ^CP (Clock)|Pin 3|Clock Input (Shifts on Low-to-High transition)| ^MR (Reset)|5V|Master Reset (Keep HIGH for normal operation)| **Example Code** This code uses the built-in //shiftOut()// function to send an 8-bit pattern to the register, which will light up LEDs or drive other parallel components. // Define pins connected to the CJMCU-164 #define DATA_PIN 2 // Connected to DSA/DSB #define CLOCK_PIN 3 // Connected to CP void setup() { // Set pins as outputs pinMode(DATA_PIN, OUTPUT); pinMode(CLOCK_PIN, OUTPUT); } void loop() { // Example 1: Send a binary pattern (B10101010) // This will turn on every other output pin (Q0-Q7) shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, 0b10101010); delay(1000); // Example 2: "Walking" bit (Light one LED at a time) for (int i = 0; i < 8; i++) { byte pattern = (1 << i); shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, pattern); delay(200); } } **Key Technical Details** * **No Latch:** Because there is no latch (RCLK), the outputs will "flicker" briefly as new data bits are shifted through the register. * **Data Inputs:** The board typically has two data inputs (A and B) that are AND-gated. For standard use, tie them together or pull one HIGH and send data to the other. * **Shift Direction:** You can use LSBFIRST or MSBFIRST in the //shiftOut()// function, depending on which output pin (Q0 or Q7) you want to represent the first bit. ====== Source ====== https://docs.arduino.cc/tutorials/communication/guide-to-shift-out/ \\ ===== Communication topics on lamaPLC ===== {{topic>communication}} \\ \\ {{tag>CJMCU-164 SN74HC164D 8-bit_Shift_Register SN74HC164D communication 7-segment CJMCU Arduino}} \\ This page has been accessed for: Today: {{counter|today}}, Until now: {{counter|total}}