Exercise 2.1: Debounce
Welcome to Module 2! In Module 1, you built a cascading decade counter that counts from 0-99. You might have noticed that sometimes when you pressed the button once, the counter jumped by 2 or even 3 numbers. This wasn't a problem with your circuit – it's a real phenomenon called button bounce, and in this exercise, you'll learn how to fix it!
By the end of this exercise, you'll understand why buttons bounce, how to visualize the problem with an LED, and how to solve it using a debounce circuit. You'll then apply this solution to make your cascading decade counter work perfectly.
INSERT VIDEO OF BOUNCING BUTTON CAUSING COUNTER TO SKIP, THEN DEBOUNCED BUTTON WORKING SMOOTHLY
1) Understanding Button Bounce
What is Button Bounce?
When you press a mechanical button, you might think the connection happens instantly and cleanly. In reality, the metal contacts inside the button physically bounce against each other several times before settling into a stable connection.
This bouncing happens incredibly fast – usually within 5-50 milliseconds – but it's fast enough that electronic circuits can detect each bounce as a separate button press.
Think of it like dropping a basketball. When the ball hits the ground, it doesn't just stick – it bounces several times before settling. Similarly, when you press a button, the internal contacts bounce several times before making stable contact.
Why This Matters
For simple circuits like turning an LED on and off, button bounce doesn't matter – the LED just flickers for a few milliseconds, which you probably won't notice.
But for counting circuits, each bounce is registered as a separate count. This is why your cascading decade counter from Module 1 sometimes skipped numbers!
2) Visualizing Button Bounce
Let's see button bounce in action by building a simple circuit that makes the problem visible.
LED Bounce Detector
1. With your power OFF, set up a simple circuit with a button connected to an LED.
2. Connect one leg of the button to 5V.
3. Connect the other leg of the button to one leg of an LED (long leg/anode).
4. Connect a 220Ω resistor from the other leg of the LED (short leg/cathode) to GND.
5. Turn your power ON.
INSERT PHOTO OF SIMPLE BUTTON + LED CIRCUIT
6. Press the button quickly and watch carefully. You might see the LED flicker very briefly as the button bounces.
7. Try pressing the button in different ways – quickly, slowly, firmly, lightly – to see how bounce varies.
The flickering you see is the LED turning on and off with each bounce. It happens so fast that it's hard to see with your eyes, but your counter circuit sees every single bounce as a separate signal.
3) The Debounce Solution: RC Circuits
To fix button bounce, we need to "smooth out" the bouncing signal so that multiple bounces are treated as a single button press. We do this with an RC circuit – a combination of a Resistor and a Capacitor.
What is a Capacitor?
A capacitor is a component that stores electrical charge, similar to a tiny rechargeable battery. Unlike a battery, a capacitor charges and discharges very quickly.
Think of a capacitor like a water balloon:
- When you turn on a faucet (apply voltage), the balloon fills with water (charges up)
- When you turn off the faucet, water slowly drains out (discharges)
- The bigger the balloon, the more water it holds and the longer it takes to drain
Capacitors are measured in Farads (F), but the capacitors you'll use are much smaller:
- Microfarads (µF) = 10⁻⁶ F
- Nanofarads (nF) = 10⁻⁹ F
- Picofarads (pF) = 10⁻¹² F
How RC Circuits Work
When you combine a resistor and capacitor, you create a circuit that takes time to charge and discharge. This time delay is exactly what we need to ignore button bounces!
Here's how it works:
- When you press the button, the capacitor starts charging through the resistor
- As the capacitor charges, the voltage rises gradually instead of jumping instantly
- Button bounces cause tiny voltage fluctuations, but the capacitor "smooths them out"
- By the time the voltage reaches the threshold the IC needs, the bouncing has stopped
- Result: the IC only sees one clean rising edge instead of multiple bouncy ones
The charging time depends on the RC time constant:
- Time constant (τ) = R × C
- After 5τ, the capacitor is about 99% charged
For example:
- 10kΩ resistor × 10µF capacitor = 0.1 seconds = 100ms
- After 5 × 100ms = 500ms, the capacitor is fully charged
4) Building a Debounce Circuit
Now let's build a proper debounce circuit for your button. You'll need:
- 1 × 10kΩ resistor
- 1 × 10µF capacitor
Electrolytic Capacitors and Polarity
The 10µF capacitor you'll use is an electrolytic capacitor. Unlike resistors, these capacitors have polarity – they must be connected in the correct direction or they can be damaged.
Electrolytic capacitors have two legs:
- Positive leg (anode): Usually longer, connected to positive voltage
- Negative leg (cathode): Shorter, marked with a stripe, connected to ground
Wiring the Debounce Circuit
Let's add a debounce circuit to a single button that controls your counter's clock input.
1. With your power OFF, remove any existing button connected to your counter's clock pin (pin 1 of your first CD4026).
2. Place your new button on the breadboard across the center gap.
3. Connect one side of the button to GND.
4. On the other side of the button, connect:
a. A 10kΩ resistor to 5V (this is called a "pull-up resistor")
b. The positive leg of a 10µF capacitor to this same row
c. A wire to the clock pin (pin 1) of your CD4026
5. Connect the negative leg of the 10µF capacitor to GND.
INSERT PHOTO OF DEBOUNCE CIRCUIT WIRING
INSERT CIRCUIT DIAGRAM OF DEBOUNCE CIRCUIT
Let's understand what each component does:
Pull-up resistor (10kΩ to 5V):
- When the button is NOT pressed, this resistor "pulls" the voltage up to 5V (HIGH)
- This ensures the signal is always in a known state (not "floating")
Capacitor (10µF):
- Smooths out voltage changes caused by button bounce
- Creates a gradual voltage rise instead of instant jumps
Button to GND:
- When pressed, connects the circuit to ground
- When released, the pull-up resistor brings voltage back to HIGH
6. Turn your power ON.
7. Test your debounced button by pressing it multiple times. The counter should increment by exactly 1 with each press!
If your counter doesn't increment or behaves strangely:
- Check the capacitor polarity (positive to button, negative to GND)
- Verify the pull-up resistor connects to 5V
- Make sure all components share the same row on the breadboard
- Use your multimeter to check voltage at the clock pin: should be ~5V when not pressed, ~0V when pressed
- Try pressing the button more firmly and releasing completely
5) Understanding the Debounce Timing
The values we chose (10kΩ and 10µF) give us:
- RC time constant: 10,000Ω × 0.00001F = 0.1 seconds = 100ms
- Full charge time: 5 × 100ms = 500ms
This means it takes about 100ms for the voltage to reach the switching threshold, which is plenty of time for the bouncing to stop (bouncing typically lasts 5-50ms).
Experimenting with Different Values
If you have other resistors and capacitors available, you can experiment:
Larger R or C → Slower response:
- 100kΩ resistor or 100µF capacitor makes the button feel "sluggish"
- Good for very bouncy buttons, but annoying for rapid counting
Smaller R or C → Faster response:
- 1kΩ resistor or 1µF capacitor responds quickly
- Might not fully eliminate bounce on cheap buttons
The 10kΩ + 10µF combination is a good balance for most applications.
6) Debouncing Your Cascading Counter
Now that you understand debouncing, let's apply it to your full cascading decade counter from Module 1's project!
Your counter has multiple buttons:
- One button for incrementing the count
- One button for reset
Let's debounce both of them.
Debouncing the Increment Button
1. Keep the debounce circuit you just built for the increment button connected to the first CD4026's clock pin.
This debounces the main counting button. Test it by counting from 0 to 20 – each press should increment by exactly 1!
Debouncing the Reset Button
2. Build a second debounce circuit for your reset button using the same components:
- 10kΩ pull-up resistor to 5V
- 10µF capacitor (watch polarity!)
- Button connected to GND
3. Connect the debounced output to the reset pins (pin 15) of both CD4026 ICs.
INSERT PHOTO OF CASCADING COUNTER WITH BOTH BUTTONS DEBOUNCED
4. Test your reset button. It should cleanly reset the display to 00 every time you press it.
If the reset button triggers multiple times:
- Double-check capacitor polarity
- Verify the pull-up resistor goes to 5V, not GND
- Make sure the button connects to GND when pressed
- The reset might be triggering on the falling edge instead of rising edge
7) Why Pull-Up Resistors Matter
You might wonder: why do we need the 10kΩ pull-up resistor at all? Can't we just connect the button between 5V and the clock pin?
The pull-up resistor serves two important purposes:
1. Prevents floating inputs: When the button is not pressed, without a pull-up resistor, the clock pin would be floating – not connected to anything. Floating inputs can randomly pick up electrical noise and trigger the circuit unexpectedly.
2. Limits current: When you press the button, if one side were directly connected to 5V, pressing it would create a short circuit from 5V to GND. The resistor limits the current flow, protecting your power supply.
8) Advanced: Pull-Down vs Pull-Up
In this exercise, we used a pull-up resistor (connected to 5V), which means:
- Normal state: HIGH
- Pressed state: LOW
- Counter increments on the rising edge when you release the button
You could also use a pull-down resistor (connected to GND), which would give:
- Normal state: LOW
- Pressed state: HIGH
- Counter increments on the rising edge when you press the button
Both work fine – it's just a matter of preference and what feels more natural. Pull-up is more common in digital circuits.
9) Reading Circuit Diagrams
Engineers use circuit diagrams (also called schematics) to document circuits in a standardized way. Here's how the debounce circuit looks as a schematic:
Common schematic symbols you should know:
| Component | Symbol | Description |
|---|---|---|
| Resistor | ![]() |
Limits current flow |
| Capacitor | ![]() |
Stores charge |
| Button/Switch | ![]() |
Manual on/off control |
| Ground | ![]() |
0V reference point |
| 5V/VCC | ![]() |
Positive power supply |
Reading schematics is a crucial skill in electronics. Instead of showing the physical layout (where things go on the breadboard), schematics show the logical connections between components.
10) Challenge: Debouncing Without a Capacitor
For an extra challenge, there are other ways to debounce a button:
Hardware method: Use a Schmidt trigger IC (like the 74HC14) which has built-in hysteresis to ignore small voltage fluctuations.
Software method: If you were using a microcontroller (like Arduino), you could read the button state multiple times and only register a press if it's stable for 50ms.
But the RC debounce circuit you built is simple, cheap, and works great for our counter!
11) Recap
Congratulations! You've learned:
✓ Why mechanical buttons bounce and how it affects counting circuits
✓ How to visualize button bounce with an LED
✓ What capacitors are and how they store charge
✓ How RC circuits smooth out voltage changes
✓ How to calculate RC time constants
✓ How to build a debounce circuit with a pull-up resistor and capacitor
✓ How to read basic circuit diagrams
✓ How to apply debouncing to multiple buttons
Your cascading counter should now work perfectly, incrementing by exactly 1 with each button press!
Final Submission
In the next exercise, you'll learn about timing circuits including crystal oscillators and the 555 timer IC. You'll make your counter tick automatically like a real clock instead of requiring manual button presses!




