Schmitt trigger debounce and oscillator
Build it step by step
0 of 8 doneWire the power
Pins 14 and 7, unused inputs to ground.
Build the debounce
10k pull-up, button and 100 nF on pins 1 and 2.
Wire the first LED
Pin 3 through 4.7 kilohm to an LED.
Test the button
The LED lights cleanly while pressed.
Build the oscillator
100k from pin 4 to pins 5 and 6, 10 uF to ground.
Add the second LED
Pin 4 through 4.7 kilohm.
Watch the blink
About once a second.
Swap to 100 nF
Speed up to an audible tone.
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
- Integrated CircuitsBuy
- SwitchesBuy
- PassivesBuyResistor 10 kΩ × 1
- PassivesBuyResistor 100 kΩ × 1
- PassivesBuyResistor 4.7 kΩ × 2
- PassivesBuy
- PassivesBuy
- SemiconductorsBuyLED 5 mm red × 2
- PowerBuy
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| 5 V adapter positive | Red rail | Supply |
| 5 V adapter negative | Blue rail | Ground |
| CD4093 pin 14 (VDD) and pin 7 (VSS) | Red rail and blue rail | Power |
| Pins 8, 9, 12 and 13 (unused gates) | Blue rail | Unused CMOS inputs must never float |
| Debounce: red rail to 10k to node N, button from N to GND, 100 nF from N to GND | Pins 1 and 2 to N | Gate A used as an inverter |
| Pin 3 (output A) | 4.7 kilohm to LED anode, LED cathode to GND | Lit while the button is held |
| Oscillator: pins 5 and 6 tied together as the gate B input | 100k from pin 4 to pins 5 and 6 | Feedback resistor |
| Capacitor from pins 5 and 6 to GND | 10 uF (plus on pins 5 and 6) for a blink, or 100 nF for a tone | Sets the speed |
| Pin 4 (output B) | 4.7 kilohm to the second LED anode, cathode to GND | Blinking 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.
| Check | Expected |
|---|---|
| Button held | LED A on |
| Button released | LED A off |
| 10 uF with 100k | LED B blinks about 1.2 Hz |
| 100 nF with 100k | About 120 Hz tone on a buzzer |
| Capacitor removed from the debounce | Scope 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 →
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.
