Stufin
Home Quick Cart Profile

CD4017 - Decade Counter IC

Buy Now

Pin Configuration

  • CD4017 - Decade Counter IC Pinout and Description
  • The CD4017 is a decade counter IC, a member of the 4000 series of CMOS (Complementary Metal-Oxide-Semiconductor) logic ICs. It is a 16-pin DIP (Dual In-Line Package) IC used for counting applications. Here's a detailed explanation of each pin:
  • Pin 1 - VDD (Positive Supply Voltage)
  • Function: Positive supply voltage pin
  • Description: Connect to a positive voltage source (+Vcc) in the range of 3V to 15V. Typically, 5V or 12V is used.
  • Pin 2 - Q1 (Output)
  • Function: Output pin of the first counter stage
  • Description: This pin goes high (logic 1) when the counter reaches 1.
  • Pin 3 - Q2 (Output)
  • Function: Output pin of the second counter stage
  • Description: This pin goes high (logic 1) when the counter reaches 2.
  • Pin 4 - Q4 (Output)
  • Function: Output pin of the fourth counter stage
  • Description: This pin goes high (logic 1) when the counter reaches 4.
  • Pin 5 - Q8 (Output)
  • Function: Output pin of the eighth counter stage
  • Description: This pin goes high (logic 1) when the counter reaches 8.
  • Pin 6 - CLK (Clock Input)
  • Function: Clock input pin
  • Description: This pin is used to feed the clock signal to the counter. A rising edge on this pin increments the counter.
  • Pin 7 - Enable (Enable Input)
  • Function: Enable input pin
  • Description: When this pin is high (logic 1), the counter is enabled, and when it's low (logic 0), the counter is disabled.
  • Pin 8 - Reset (Reset Input)
  • Function: Reset input pin
  • Description: When this pin is high (logic 1), the counter is reset to 0. The counter will start counting from 0 when the reset pin is brought low (logic 0) again.
  • Pin 9 - Q3 (Output)
  • Function: Output pin of the third counter stage
  • Description: This pin goes high (logic 1) when the counter reaches 3.
  • Pin 10 - Q5 (Output)
  • Function: Output pin of the fifth counter stage
  • Description: This pin goes high (logic 1) when the counter reaches 5.
  • Pin 11 - Q6 (Output)
  • Function: Output pin of the sixth counter stage
  • Description: This pin goes high (logic 1) when the counter reaches 6.
  • Pin 12 - Q7 (Output)
  • Function: Output pin of the seventh counter stage
  • Description: This pin goes high (logic 1) when the counter reaches 7.
  • Pin 13 - Q9 (Output)
  • Function: Output pin of the ninth counter stage
  • Description: This pin goes high (logic 1) when the counter reaches 9.
  • Pin 14 - Q10 (Output)
  • Function: Output pin of the tenth counter stage
  • Description: This pin goes high (logic 1) when the counter reaches 10.
  • Pin 15 - VSS (Negative Supply Voltage)
  • Function: Negative supply voltage pin
  • Description: Connect to a negative voltage source (GND) or 0V.
  • Pin 16 - Carry Out (Carry Output)
  • Function: Carry output pin
  • Description: This pin goes high (logic 1) when the counter reaches 10, indicating that the counter has overflowed.
  • Connecting the Pins:
  • 1. Connect VDD (Pin 1) to a positive voltage source (+Vcc) in the range of 3V to 15V.
  • 2. Connect VSS (Pin 15) to a negative voltage source (GND) or 0V.
  • 3. Connect the CLK (Pin 6) to a clock signal source.
  • 4. Connect the Enable (Pin 7) to a logic-high signal to enable the counter.
  • 5. Connect the Reset (Pin 8) to a logic-high signal to reset the counter.
  • 6. Connect the output pins (Q1 to Q10) to the desired load, such as LEDs, transistors, or other logic ICs.
  • 7. Connect the Carry Out (Pin 16) to a logic circuit or another counter IC to cascade the counters.
  • Note: Ensure that the voltage and current ratings of the CD4017 IC are not exceeded during operation. Additionally, use proper decoupling capacitors and voltage regulators to ensure stable power supply to the IC.

Code Examples

CD4017 Decade Counter IC Documentation
Overview
The CD4017 is a 5-stage Johnson decade counter integrated circuit (IC) used for counting and decoding applications. It is a popular IC used in digital circuits, microcontrollers, and other electronic devices. The CD4017 can be used to generate a binary count from 0 to 9, making it suitable for various applications such as clocks, timers, and sequencers.
Pinout
The CD4017 IC has 16 pins, with the following pinout:
| Pin Number | Pin Name | Function |
| --- | --- | --- |
| 1 | VCC | Positive Supply Voltage |
| 2 | Q0 | Output (Binary 0) |
| 3 | Q1 | Output (Binary 1) |
| 4 | Q2 | Output (Binary 2) |
| 5 | Q3 | Output (Binary 3) |
| 6 | Q4 | Output (Binary 4) |
| 7 | Q5 | Output (Binary 5) |
| 8 | Q6 | Output (Binary 6) |
| 9 | Q7 | Output (Binary 7) |
| 10 | Q8 | Output (Binary 8) |
| 11 | Q9 | Output (Binary 9) |
| 12 | CLK | Clock Input |
| 13 | CLR | Clear Input (Active Low) |
| 14 | ENABLE | Enable Input (Active High) |
| 15 | GND | Ground |
| 16 | VCC | Positive Supply Voltage |
Code Examples
### Example 1: Basic Decade Counter using CD4017
In this example, we will use the CD4017 to generate a decimal count from 0 to 9. We will connect the clock input (CLK) to a push-button, and the outputs (Q0-Q9) to LEDs to display the count.
Circuit Diagram
Connect the push-button to pin 12 (CLK) and the LEDs to pins 2-11 (Q0-Q9). Connect VCC to +5V and GND to GND.
Arduino Code
```c
const int clockPin = 2;  // Clock input
const int resetPin = 3;  // Clear input
const int enablePin = 4;  // Enable input
int count = 0;
void setup() {
  pinMode(clockPin, INPUT);
  pinMode(resetPin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  
  digitalWrite(resetPin, HIGH);  // Initialize clear input to high
  digitalWrite(enablePin, HIGH);  // Initialize enable input to high
}
void loop() {
  if (digitalRead(clockPin) == LOW) {
    count++;
    if (count > 9) {
      count = 0;
    }
    delay(50);  // Debounce time
  }
  
  // Display count on LEDs
  if (count == 0) {
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    ...
  } else if (count == 1) {
    digitalWrite(2, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    ...
  }
  ...
}
```
### Example 2: CD4017 as a Sequencer
In this example, we will use the CD4017 to sequence a series of events. We will connect the clock input (CLK) to a timer circuit, and the outputs (Q0-Q9) to relays that control different loads.
Circuit Diagram
Connect the timer circuit to pin 12 (CLK) and the relays to pins 2-11 (Q0-Q9). Connect VCC to +5V and GND to GND.
Arduino Code
```c
const int clockPin = 2;  // Clock input
const int relayPins[] = {3, 4, 5, 6, 7, 8, 9, 10, 11};  // Relay pins
void setup() {
  pinMode(clockPin, INPUT);
  
  for (int i = 0; i < 9; i++) {
    pinMode(relayPins[i], OUTPUT);
  }
}
void loop() {
  static int sequence = 0;
  
  if (digitalRead(clockPin) == LOW) {
    sequence++;
    if (sequence > 9) {
      sequence = 0;
    }
    
    // Sequence the relays
    for (int i = 0; i < 9; i++) {
      if (i == sequence) {
        digitalWrite(relayPins[i], HIGH);
      } else {
        digitalWrite(relayPins[i], LOW);
      }
    }
    delay(1000);  // Time between sequence steps
  }
}
```
Note: These examples are for illustration purposes only and may require additional components and modifications to work in a real-world application.