0Pricing
Arduino & IoT Academy · Lezione

Perché i pulsanti hanno il “rimbalzo”

Osservi i falsi trigger creati da un contatto.

Perché i pulsanti hanno il “rimbalzo” è una lezione Arduino & IoT Academy gratuita su CoddyKit. Questa è la lezione 1 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Arduino & IoT Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Arduino & IoT Academy include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

One Press, Many Signals

You press a button once, but your Arduino may see several presses. This sneaky problem is called bounce, and it trips up almost every beginner. 😅

Inside a Push Button

A button is just two metal contacts that touch when you press. They feel solid to your finger, but at the microsecond level they are anything but.

Metal That Chatters

When the contacts meet, they physically vibrate for a few milliseconds before settling. Each tiny touch and break is a separate electrical event.

What the Pin Sees

During that vibration, the pin reads a burst of rapid HIGH-LOW flips instead of one clean change. Your code can count every flip as a press.

Why the Loop Catches It

Your loop() runs millions of times per second, far faster than the bounce settles. So it samples the noise again and again.

A Counter Gone Wild

Picture a counter that adds one per press. One real tap can jump it by three or four because of multiple false triggers.

if (digitalRead(BTN) == LOW) {
  count++;  // may fire several times per tap
}

It Happens on Release Too

Bounce strikes when you let go as well, not just when you press. Both edges of the signal can stutter and confuse your logic.

How Long It Lasts

Most bounce settles within about 5 to 20 milliseconds. It is brief, but to a fast microcontroller that is an eternity of noise.

Spot It Yourself

Print a message every time the pin goes LOW and tap once. Seeing several lines in the Serial Monitor proves bounce is real.

if (digitalRead(BTN) == LOW)
  Serial.println("pressed");

Hardware or Software Fix

You can tame bounce with a small capacitor in the circuit, or with timing logic in code. Software is cheaper and far more common.

The Core Idea

The fix is to wait briefly after the first change and ignore the rest. Confirm the button is truly stable before you act on it.

Quick Check

Let's confirm what causes a button to bounce.

Recap: Bounce Basics

You learned that a button's contacts bounce, sending noisy flips that fool fast code. Next you'll silence that noise with simple timing. 🎯

Domande Frequenti

La lezione «Perché i pulsanti hanno il “rimbalzo”» è gratuita?

Sì — il testo completo di «Perché i pulsanti hanno il “rimbalzo”» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Arduino & IoT Academy, passa a CoddyKit PRO. Il corso Arduino & IoT Academy include 4 lezioni in totale.

Cosa imparerò in «Perché i pulsanti hanno il “rimbalzo”»?

Osservi i falsi trigger creati da un contatto. Eserciti Arduino & IoT Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Arduino & IoT Academy?

Non è richiesta alcuna esperienza precedente. Arduino & IoT Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 1 di 4.

Quanto tempo richiede la lezione «Perché i pulsanti hanno il “rimbalzo”»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Arduino & IoT Academy?

Sì. Ogni lezione Arduino & IoT Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Perché i pulsanti hanno il “rimbalzo”
  2. Eseguire il debounce con millis()
  3. Salvare un valore in EEPROM
  4. Ricordare un contatore dopo il reset
← Torna a Arduino & IoT Academy