One-Button ON/OFF Circuit with CD4017 IC

Introduction

Most electronic devices use a toggle switch or push button to turn ON and OFF. But what if you could do this with just one button? That’s exactly what this circuit achieves using the CD4017 Decade Counter IC. It’s simple, efficient, and a great project for hobbyists and makers.

How It Works

The CD4017 is a decade counter/divider IC with 10 decoded outputs (Q0–Q9). Each time it receives a clock pulse, it advances to the next output pin.

  • When you press the button, the IC receives a clock pulse.
  • The first press activates Q0 → ON state.
  • The second press activates Q1 → OFF state.
  • The cycle continues, but by wiring only two outputs (Q0 and Q1), we can create a neat ON/OFF toggle.

 

Circuit Components

  • CD4017 Decade Counter IC
  • Push Button (momentary switch)
  • Resistors (for pull-down/pull-up configuration, Current limiting resistor for Output LED)
  • Capacitor (for debounce filtering)
  • LED (to demonstrate ON/OFF switching)
  • Power Supply (5Vdc)

One Button On/Off Circuit


 

Circuit Explanation

  1. Clock Input (Pin 14): A switch (S1) is connected between U1 Pin 14 and VCC. Each press sends a pulse.
  2. One resistor R1, 470 Ohm pull down resistor, is connected between Pin-14 and GND.
  3. Reset (Pin 15): Ensures the IC starts from Q0 when powered ON. Pin-15 is connected to Pin-4.  So that on the next press, it will reset the Output, and LED, LD1, will be OFF.
  4. Outputs (Q0 & Q1):
    • Q0 → Connected to the load, LED LD1, through R2 Resistor.
    • Q1 → Connected to reset or directly used to turn OFF the load.
  5. Debouncing: A small capacitor C1, 100nF, across the button ensures clean pulses without multiple triggers.

 

 Applications

  • DIY gadgets with a single ON/OFF button
  • Lamp or fan control circuits
  • Embedded projects where minimal switches are desired
  • Learning tool for digital electronics and counters

 

Advantages

  • Reduces switch count (only one button needed)
  • Easy to build and understand
  • Low-cost components
  • Can be extended for more functions using other outputs of CD4017

 

 Conclusion

This one-button ON/OFF circuit using CD4017 is a perfect example of how digital ICs can simplify everyday electronics. With just a push button and a counter IC, you can toggle devices ON and OFF elegantly. It’s a great beginner-friendly project that also teaches the fundamentals of counters and sequential logic.

 





TM1637 4-Digit 7-Segment LED Display with Arduino Uno

Introduction

If you’ve ever wanted to display numbers in your Arduino projects — whether it’s a clock, a counter, or sensor readings — the TM1637 4-digit 7-segment LED display is one of the easiest and most affordable solutions. It uses only two data pins, thanks to the onboard TM1637 driver IC, which simplifies wiring and coding compared to traditional 7-segment displays.

In this blog, we’ll walk through:

  • Understanding the TM1637 module
  • Pinout and wiring with Arduino Uno
  • Installing the required library
  • Example codes (basic display, scrolling, countdown, sensor integration)
  • Practical applications and project ideas
  • Troubleshooting and tips

 

Understanding the TM1637 Module

The TM1637 module is widely available in electronics shops and online marketplaces. Here’s what makes it special:

  • 4-digit 7-segment LED display: Each digit can show numbers 0–9 and some letters.
  • Colon separator: Useful for clocks and timers.
  • TM1637 driver IC: Handles multiplexing and communication, reducing pin usage.
  • Two-wire interface: Only requires CLK and DIO pins, plus VCC and GND.

 

Pinout

  • VCC → 5V
  • GND → Ground
  • DIO → Data I/O
  • CLK → Clock

Wiring TM1637 with Arduino Uno

Here’s the wiring diagram:

TM1637 Pin

Arduino Uno Pin

VCC

5V

GND

GND

DIO

Digital Pin 2

CLK

Digital Pin 3

You can change the DIO and CLK pins in your code if needed.

 

Installing the TM1637 Library

  1. Open Arduino IDE.
  2. Go to Sketch → Include Library → Manage Libraries.
  3. Search for TM1637Display.
  4. Install the library by Avishay Orpaz (commonly used).

 


 

Example Codes

1. Basic Number Display

#include <TM1637Display.h>

 

#define CLK 3

#define DIO 2

 

TM1637Display display(CLK, DIO);

 

void setup() {

  display.setBrightness(0x0f); // Max brightness

}

 

void loop() {

  display.showNumberDec(1234); // Display 1234

  delay(2000);

}

 

2. Countdown Timer

#include <TM1637Display.h>

 

#define CLK 3

#define DIO 2

 

TM1637Display display(CLK, DIO);

 

void setup() {

  display.setBrightness(0x0f);

}

 

void loop() {

  for (int i = 30; i >= 0; i--) {

    display.showNumberDec(i, true); // Show with leading zeros

    delay(1000);

  }

}

 

3. Scrolling Text (HELLO)

#include <TM1637Display.h>

 

#define CLK 3

#define DIO 2

 

TM1637Display display(CLK, DIO);

 

const uint8_t SEG_HELLO[] = {

  SEG_H, SEG_E, SEG_L, SEG_L, SEG_O

};

 

void setup() {

  display.setBrightness(0x0f);

}

 

void loop() {

  for (int i = 0; i < 5; i++) {

    display.showNumberDecEx(0, 0, true, 4, i); // Scroll effect

    display.setSegments(SEG_HELLO + i, 4, 0);

    delay(500);

  }

}

 

4. Sensor Integration (Temperature Display)

If you connect a temperature sensor like DHT11, you can display readings:

#include <TM1637Display.h>

#include <DHT.h>

 

#define CLK 3

#define DIO 2

#define DHTPIN 4

#define DHTTYPE DHT11

 

TM1637Display display(CLK, DIO);

DHT dht(DHTPIN, DHTTYPE);

 

void setup() {

  display.setBrightness(0x0f);

  dht.begin();

}

 

void loop() {

  int temp = dht.readTemperature();

  display.showNumberDec(temp);

  delay(2000);

}

 

Applications

  • Digital Clock: Combine with RTC module (DS3231).
  • Stopwatch/Timer: Great for labs, cooking, or sports.
  • Scoreboard: Display scores in games.
  • Sensor Readouts: Show temperature, distance, or voltage.
  • Counter Projects: People counter, product counter, etc.

 

Troubleshooting

  • No display? Check wiring and ensure VCC is 5V.
  • Dim display? Adjust brightness with setBrightness().
  • Wrong numbers? Verify DIO and CLK pin assignments in code.
  • Library errors? Ensure you installed the correct TM1637Display library.

 

Conclusion

The TM1637 4-digit 7-segment LED display is a powerful yet simple module for Arduino projects. With just two pins, you can build clocks, timers, counters, and sensor displays. Its versatility makes it perfect for beginners and advanced makers alike.






Seven Segment Display (SSD): A Complete Guide

Introduction

A Seven Segment Display (SSD) is one of the simplest and most widely used electronic display devices. It is primarily used to represent decimal numbers (0–9) and a limited set of characters. From digital clocks and calculators to microwave ovens and measuring instruments, SSDs remain a cost-effective and reliable solution for numeric display needs.

Structure of a Seven Segment Display

An SSD consists of seven LEDs (segments) arranged in the shape of the number "8". Each segment is labelled from a to g, and by selectively powering these segments, different numbers and characters can be displayed.

  • Segments: a, b, c, d, e, f, g
  • Optional Dot (DP): Used for decimal points in numerical displays
  • Total Pins: Usually 10 pins (7 for segments, 1 for DP, and 2 for common connections)

 

Types of Seven Segment Displays

There are two main types of SSDs based on how the LEDs are connected:

Type

Description

Example

Common Cathode (CC)

All cathodes of LEDs are tied together to ground. Segments glow when a HIGH signal is applied.

Used in microcontroller circuits

Common Anode (CA)

All anodes are tied together to Vcc. Segments glow when a LOW signal is applied.

Often used in multiplexed displays

 


 

Working Principle

The working of an SSD is based on forward biasing LEDs:

  1. Digit Formation:
    • To display "0", segments a, b, c, d, e, f are ON, while g is OFF.
    • To display "1", only segments b and c are ON.
    • To display "8", all segments are ON.

 

  1. Control Signals:
    • Each segment is controlled by a digital signal (from a microcontroller, decoder, or driver IC).
    • By combining signals, different digits are formed.

 

  1. Multiplexing:
    • In multi-digit displays, segments are shared across digits.
    • Microcontrollers rapidly switch between digits to give the illusion of continuous display.

 

Applications

Seven Segment Displays are widely used in:

  • Digital clocks and watches
  • Calculators
  • Microwave ovens and washing machines
  • Measuring instruments (voltmeters, ammeters)
  • Scoreboards and counters

 

Advantages

  • Simple design and easy interfacing
  • Low cost compared to LCDs or dot-matrix displays
  • Readable even in bright light (LED-based SSDs)

 

Limitations

  • Limited to numbers and a few characters
  • Not suitable for complex text or graphics
  • Consumes more power compared to LCDs

 

Common Cathode vs Common Anode Seven Segment Displays

1. Common Cathode (CC) Display

  • Structure: All the cathodes (negative terminals) of the seven LEDs are internally connected to a single pin.
  • Operation:
    • The common cathode pin is connected to ground (0V).
    • To light up a segment, you apply a HIGH (logic 1) signal to its corresponding pin.
  • Example:
    • To display digit "1", apply HIGH to segment pins b and c while keeping others LOW.
  • Usage:
    • Often used with microcontrollers because they can easily source current to the segments.

 

2. Common Anode (CA) Display

  • Structure: All the anodes (positive terminals) of the seven LEDs are internally connected to a single pin.
  • Operation:
    • The common anode pin is connected to Vcc (+5V).
    • To light up a segment, you apply a LOW (logic 0) signal to its corresponding pin.
  • Example:
    • To display digit "1", apply LOW to segment pins b and c while keeping others HIGH.
  • Usage:
    • Preferred in multiplexed displays, since microcontrollers can easily sink current.

 

Comparison Table

Feature

Common Cathode (CC)

Common Anode (CA)

Common Pin Connection

Ground (0V)

Vcc (+5V)

Segment Activation

Apply HIGH (1)

Apply LOW (0)

Current Flow

From segment pin → cathode

From anode → segment pin

Ease of Use

Easier with sourcing drivers

Easier with sinking drivers

Typical Application

Simple microcontroller circuits

Multiplexed multi-digit displays

 

Practical Note

  • Microcontrollers: Some microcontrollers are better at sinking current than sourcing it. In such cases, Common Anode displays are more efficient.
  • Driver ICs: ICs like 7447 (BCD to 7-segment decoder) are designed specifically for Common Anode displays, while 7448 works with Common Cathode.

 

Conclusion

The Seven Segment Display remains a cornerstone of electronic display technology. Despite the rise of LCDs and OLEDs, SSDs are still preferred in many applications due to their simplicity, durability, and cost-effectiveness. For beginners in electronics, understanding SSDs is an essential step toward mastering digital display systems.

Both Common Cathode and Common Anode SSDs serve the same purpose—displaying digits and characters—but the choice depends on the circuit design and driver compatibility. Understanding the difference is crucial when interfacing SSDs with microcontrollers, decoders, or driver ICs.

  





Basics of LDR (Light Dependent Resistor)

What is an LDR?

  • Definition: An LDR, also called a photoresistor, is a passive electronic component whose resistance decreases as the intensity of incident light increases.
  • Core Principle: It works on photoconductivity—the property of certain materials to conduct electricity better when exposed to light.


Working Principle of LDR

  • Dark Condition: In absence of light, the resistance of an LDR is very high (in megaohms).
  • Bright Condition: When exposed to light, photons excite electrons in the semiconductor material, reducing resistance drastically (to a few hundred ohms).
  • Equation: Resistance R is inversely proportional to light intensity I.

R1/I

Construction of LDR

  • Material: Made from cadmium sulfide (CdS) or cadmium selenide (CdSe).
  • Design: Zig-zag track of semiconductor material deposited on a ceramic base, with two leads for connection.
  • Encapsulation: Transparent cover allows light to fall directly on the surface.

 

Types of LDR

  1. Intrinsic LDRs
    • Made from pure semiconductors.
    • Less sensitive, used in basic applications.

 

  1. Extrinsic LDRs
    • Doped semiconductors for higher sensitivity.
    • Suitable for precise light measurement.

 

Characteristics of LDR

  • Response Time: Slow compared to photodiodes or phototransistors.
  • Spectral Response: Sensitive to visible light (400–700 nm).
  • Cost: Very inexpensive, making them popular in hobby projects.

 

Resistance Values of LDR

An LDR’s resistance varies drastically depending on the amount of light falling on it. Here’s a typical range:

Condition

Light Intensity

Approx. Resistance

Complete Darkness

0 lux

1 MΩ – 10 MΩ (very high)

Dim Light

10–100 lux (like twilight or a dim room)

100 kΩ – 500 kΩ

Normal Indoor Light

300–500 lux

10 kΩ – 50 kΩ

Bright Daylight

10,000 lux or more

200 Ω – 1 kΩ (very low)

  • In No Light (Darkness): The LDR behaves almost like an insulator, with resistance in the megaohm range.
  • In Bright Light: Resistance drops sharply, sometimes to just a few hundred ohms, allowing current to flow easily.

 

 

Applications of LDR

1. Automatic Street Lighting

  • LDRs detect ambient light.
  • At dusk, resistance drops, triggering lights ON.
  • At dawn, resistance rises, turning lights OFF.

Example: Smart city streetlamps in India use LDR-based circuits to save energy.

 

2. Solar Garden Lamps

  • LDRs ensure lamps glow only at night.
  • Integrated with rechargeable batteries and solar panels.

 

3. Camera Exposure Control

  • LDRs measure light intensity to adjust shutter speed and aperture.
  • Ensures optimal photo brightness.

 

4. Burglar Alarms

  • LDRs detect interruption of light beams.
  • If someone crosses the beam, resistance changes, triggering alarm.

 

5. Industrial Automation

  • Used in conveyor belts to detect product presence.
  • LDR sensors identify light reflection from objects.

 

Practical Examples

Example 1: Automatic Night Lamp

  • Circuit: LDR + transistor + relay + bulb.
  • Working:
    • Daytime: High resistance → transistor OFF → bulb OFF.
    • Nighttime: Low resistance → transistor ON → bulb ON.
  • Benefit: Saves electricity, widely used in homes.

 

Example 2: Line Follower Robot

  • Circuit: LDRs placed at bottom of robot.
  • Working:
    • White surface reflects more light → low resistance.
    • Black surface absorbs light → high resistance.
  • Application: Robotics competitions, industrial AGVs.

 

Example 3: Solar Tracker

  • Circuit: Two LDRs placed on either side of a panel.
  • Working:
    • If one LDR receives more light, motor adjusts panel until both LDRs sense equal light.
  • Benefit: Maximizes solar energy capture.

 

Advantages of LDR

  • Low cost and easy availability.
  • Simple design and easy to integrate.
  • Wide range of applications in automation and sensing.

 

Limitations of LDR

  • Slow response compared to photodiodes.
  • Temperature dependent—performance varies with heat.
  • Not suitable for precise scientific measurements.

 

DIY Project Idea: Smart Curtain System

  • Concept: Curtains open automatically when sunlight intensity crosses a threshold.
  • Components: LDR, Arduino, servo motor.
  • Working: Arduino reads LDR values and controls servo to open/close curtains.
  • Benefit: Energy-efficient and convenient.

 

Conclusion

LDRs are versatile, cost-effective, and beginner-friendly sensors that play a crucial role in light detection and automation. From streetlights to robots, their applications span across industries and daily life. While they have limitations in precision, their simplicity makes them indispensable for educational projects, prototypes, and practical automation systems.






 

Python: Calculating Area & Perimeter of Quadrilaterals

Quadrilaterals are polygons with four sides. They come in different types — square, rectangle, parallelogram, rhombus, trapezium (trapezoid), and kite. Each has unique formulas for area and perimeter.

In this tutorial, we’ll:

  1. Review the formulas for each quadrilateral.
  2. Write Python functions to calculate area and perimeter.
  3. Test our functions with examples.

 

Step 1: Understanding the Formulas

Here’s a quick reference table:


 

Step 2: Writing Python Functions

We’ll create modular functions — one for each quadrilateral.

 

# Square

def square(side):

    area = side ** 2

    perimeter = 4 * side

    return area, perimeter

 

# Rectangle

def rectangle(length, width):

    area = length * width

    perimeter = 2 * (length + width)

    return area, perimeter

 

# Parallelogram

def parallelogram(base, side, height):

    area = base * height

    perimeter = 2 * (base + side)

    return area, perimeter

 

# Rhombus

def rhombus(diagonal1, diagonal2, side):

    area = (diagonal1 * diagonal2) / 2

    perimeter = 4 * side

    return area, perimeter

 

# Trapezium

def trapezium(a, b, c, d, height):

    area = 0.5 * (a + b) * height

    perimeter = a + b + c + d

    return area, perimeter

 

# Kite

def kite(diagonal1, diagonal2, side1, side2):

    area = (diagonal1 * diagonal2) / 2

    perimeter = 2 * (side1 + side2)

    return area, perimeter

 

Step 3: Testing the Functions

Code:

print("Square:", square(5))             # side = 5

print("Rectangle:", rectangle(10, 6))   # length = 10, width = 6

print("Parallelogram:", parallelogram(8, 5, 4)) # base=8, side=5, height=4

print("Rhombus:", rhombus(6, 8, 5))     # diagonals=6,8; side=5

print("Trapezium:", trapezium(10, 6, 5, 7, 4)) # sides=10,6,5,7; height=4

print("Kite:", kite(8, 6, 5, 7))        # diagonals=8,6; sides=5,7

 

Step 4: Output

Square: (25, 20)

Rectangle: (60, 32)

Parallelogram: (32, 26)

Rhombus: (24.0, 20)

Trapezium: (32.0, 28)

Kite: (24.0, 24)

 



Key Takeaways

  • Each quadrilateral has unique formulas — understanding them is crucial before coding.
  • Python functions make calculations modular and reusable.
  • You can extend this tutorial by:
    • Adding user input (input() function).
    • Creating a menu-driven program to choose the quadrilateral.
    • Visualizing shapes with Matplotlib for better learning.