0Pricing
Arduino & IoT Academy · Lección

Por qué los botones «rebotan»

Observe los disparos falsos que genera un contacto.

Por qué los botones «rebotan» es una lección gratuita de Arduino & IoT Academy en CoddyKit. Esta es la lección 1 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Arduino & IoT Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Arduino & IoT Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

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. 🎯

Preguntas frecuentes

¿La lección «Por qué los botones «rebotan»» es gratis?

Sí — el texto completo de «Por qué los botones «rebotan»» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Arduino & IoT Academy, actualiza a CoddyKit PRO. El curso de Arduino & IoT Academy incluye 4 lecciones en total.

¿Qué aprenderé en «Por qué los botones «rebotan»»?

Observe los disparos falsos que genera un contacto. Practicas Arduino & IoT Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Arduino & IoT Academy?

No se requiere experiencia previa. Arduino & IoT Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 1 de 4.

¿Cuánto tiempo toma la lección «Por qué los botones «rebotan»»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Arduino & IoT Academy?

Sí. Cada lección de Arduino & IoT Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Por qué los botones «rebotan»
  2. Eliminar rebotes con millis()
  3. Almacenar un valor en EEPROM
  4. Recordar un contador después de reiniciar
← Volver a Arduino & IoT Academy