Schmitt Trigger is a runnable microcontroller simulation example on SensBench — open the wired circuit, inspect the code, and compile real firmware in your browser, no install needed. Last updated Aug 14, 2026.

FREE SIMULATOR EXAMPLE · ADVANCED

Schmitt Trigger

This example samples a Schmitt trigger on the Arduino Uno — an op-amp with positive feedback that turns a noisy analog signal into a clean digital one. The Serial Plotter shows the ragged input and the crisp output side by side.

Board Arduino Uno (ATmega328P) + analog SPICE circuit
Difficulty advanced
Category circuits
Libraries None — just the Arduino core
Runs in Sensbench browser simulator — free, no account
Arduino Uno sampling a Schmitt trigger's noisy input and clean output on A0 and A1 in the Sensbench simulator

The exact circuit you get when you open this example — already wired, ready to run.

The sketch

// Schmitt trigger — cleans noisy input
void setup() { Serial.begin(9600); }
void loop() {
  int raw = analogRead(A0);
  int out = analogRead(A1);
  Serial.print(raw); Serial.print(","); Serial.println(out);
  delay(10);
}

How it works

The Schmitt trigger is a comparator with positive feedback: the output feeds back through a resistor to the non-inverting input, shifting the threshold depending on the output state. A noisy input crossing the band gets a clean, decisive output — the input can wobble, but the output only flips when the signal genuinely crosses a threshold.

The sketch samples the input on A0 and the output on A1 every 10 ms, printing both as a comma-separated pair for the Serial Plotter. The visual contrast is the lesson: the raw input trace is ragged, the output trace is a clean square wave — same information, one of them usable by digital logic.

Before you build it for real

The hysteresis band is a trade-off, not a magic filter: make it too narrow and noise still gets through; too wide and real signal changes get ignored. The thresholds drift with the supply rail — the feedback-derived references are proportional to Vcc, so a sagging rail shifts the whole decision point. And the op-amp’s output swing limits the hysteresis range: on an LM358 that cannot reach the rails, the computed thresholds are compressed, and the effective band is smaller than the resistor math predicts. For fast digital signals, a real Schmitt-trigger logic gate (74HC14) beats any op-amp circuit — this example is about seeing the principle.

Get the parts

Related examples

FAQ

What is hysteresis and why does it clean up noise?

Hysteresis means the turn-on threshold is different from the turn-off threshold. A noisy signal wandering near a single threshold trips the comparator constantly; with hysteresis, once the output flips high, the input must drop well below the turn-on point before it flips back. The noise between the two thresholds is simply ignored.

Where do the two thresholds come from?

Positive feedback: a resistor from the output to the non-inverting input shifts the reference depending on the current output state. Output high raises the threshold; output low lowers it. The resistor ratio sets the gap — the hysteresis band — and the input must cross the whole band to change state.