Projects / Schmitt trigger debounce and oscillator

Schmitt trigger debounce and oscillator

Beginner1.3 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. Wire the power

    Pins 14 and 7, unused inputs to ground.

  2. Build the debounce

    10k pull-up, button and 100 nF on pins 1 and 2.

  3. 12.5 mA

    Wire the first LED

    Pin 3 through 4.7 kilohm to an LED.

  4. 12.5 mA

    Test the button

    The LED lights cleanly while pressed.

  5. Build the oscillator

    100k from pin 4 to pins 5 and 6, 10 uF to ground.

  6. 12.5 mA

    Add the second LED

    Pin 4 through 4.7 kilohm.

  7. Watch the blink

    About once a second.

  8. Swap to 100 nF

    Speed up to an audible tone.

In short

How do you build a schmitt trigger debounce and oscillator?

A quad Schmitt NAND cleans up a noisy button and, with a resistor and capacitor, turns into a simple oscillator. You need CD4093 quad NAND Schmitt trigger, Tactile push button 6 mm, Resistor 10 kΩ, Resistor 100 kΩ, Resistor 4.7 kΩ × 2, Ceramic Capacitor 100 nF × 2, Electrolytic capacitor 10 µF, LED 5 mm red × 2, 5 V 2 A USB adapter, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points. It takes 8 steps and about 75 minutes.

Level
Beginner
Time
About 75 min
Parts
11

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
5 V adapter positiveRed railSupply
5 V adapter negativeBlue railGround
CD4093 pin 14 (VDD) and pin 7 (VSS)Red rail and blue railPower
Pins 8, 9, 12 and 13 (unused gates)Blue railUnused CMOS inputs must never float
Debounce: red rail to 10k to node N, button from N to GND, 100 nF from N to GNDPins 1 and 2 to NGate A used as an inverter
Pin 3 (output A)4.7 kilohm to LED anode, LED cathode to GNDLit while the button is held
Oscillator: pins 5 and 6 tied together as the gate B input100k from pin 4 to pins 5 and 6Feedback resistor
Capacitor from pins 5 and 6 to GND10 uF (plus on pins 5 and 6) for a blink, or 100 nF for a toneSets the speed
Pin 4 (output B)4.7 kilohm to the second LED anode, cathode to GNDBlinking LED

Code

A button does not close cleanly: the contacts bounce for a few milliseconds, which a counter or a flip-flop sees as many presses. A Schmitt trigger gate is the simple fix, because its input has two thresholds, a higher one to switch up and a lower one to switch down, so a slowly changing or noisy signal produces one clean transition. In this build, the button pulls a node to ground against a 10 kilohm pull-up with a 100 nanofarad capacitor across it, which smooths the bounce into a slow curve. The gate sees that curve cross the threshold only once and gives a clean output, inverted so that the LED is on while the button is pressed. The second half of the lab uses the same chip as an oscillator. A resistor from the output back to the input charges and discharges a capacitor, and the Schmitt thresholds make the gate flip each time the capacitor reaches one of them, so the output is a square wave at about 1.2 divided by RC. With 10 microfarads it blinks about once a second, and with 100 nanofarads it gives about 120 hertz. CMOS gates cannot drive an LED hard at 5 volts, so the resistors are 4.7 kilohms and the LEDs are dim. Always tie unused inputs of a CMOS chip to ground, because floating inputs can oscillate, draw extra current and lead to odd behaviour.

Build notes (no code needed for this build)

CD4093 pins: 1, 2 input A; 3 output A; 4 output B; 5, 6 input B; 7 VSS (GND); 8, 9 input C; 10 output C; 11 output D; 12, 13 input D; 14 VDD.
Each gate is a 2-input NAND with Schmitt inputs. With both inputs tied together a gate is an inverter with hysteresis.
The Schmitt input has two thresholds: at 5 V it switches up at about 2.9 V and down at about 1.9 V (typical, the datasheet gives a range).

Debounce: R = 10 kilohm and C = 100 nF give a time constant of 1 ms. When the button bounces, the capacitor smooths it and the two thresholds make the output change only once.
The output is inverted: the LED is on while the button is pressed.
To see the bounce, look at node N and output A on an oscilloscope with and without the capacitor.

Oscillator: gate B with 100 kilohm from its output to its input and a capacitor from its input to ground.
Frequency is about 1.2 / (R x C): with 10 uF and 100 kilohm (RC = 1 s) about 1.2 Hz, a visible blink;
with 100 nF and 100 kilohm (RC = 10 ms) about 120 Hz, which you can hear on a small buzzer connected to the output.

CMOS outputs are weak at 5 V, so the LEDs use 4.7 kilohm resistors and light dimly.
Keep every unused input tied to ground.

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Button heldLED A on
Button releasedLED A off
10 uF with 100kLED B blinks about 1.2 Hz
100 nF with 100kAbout 120 Hz tone on a buzzer
Capacitor removed from the debounceScope shows bounce

If it does not work

Nothing happens

Check power on pins 14 and 7.

Erratic behaviour

Check the unused gate inputs are on ground.

LED A always on

Check the pull-up and the button wiring.

No oscillation

Check the feedback resistor and the capacitor.

LEDs very dim

Normal with CMOS outputs and 4.7 kilohm.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the schmitt trigger debounce and oscillator?

CD4093 quad NAND Schmitt trigger, Tactile push button 6 mm, Resistor 10 kΩ, Resistor 100 kΩ, Resistor 4.7 kΩ × 2, Ceramic Capacitor 100 nF × 2, Electrolytic capacitor 10 µF, LED 5 mm red × 2, 5 V 2 A USB adapter, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points.

How long does the schmitt trigger debounce and oscillator take to build?

About 75 minutes for a beginner maker, in 8 steps.

How do I know the schmitt trigger debounce and oscillator works?

Button held: LED A on. Button released: LED A off. 10 uF with 100k: LED B blinks about 1.2 Hz.

Nothing happens: what should I check?

Check power on pins 14 and 7.

Erratic behaviour: what should I check?

Check the unused gate inputs are on ground.

LED A always on: what should I check?

Check the pull-up and the button wiring.

No oscillation: what should I check?

Check the feedback resistor and the capacitor.