0Pricing
Arduino & IoT Academy · Lektion

INPUT oder INPUT_PULLUP

Erfahren Sie, warum ein offener Pin falsche Werte liefert und Pull-ups das beheben

INPUT oder INPUT_PULLUP ist eine kostenlose Arduino & IoT Academy-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Arduino & IoT Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Pins Can Listen Too

So far your pins pushed signals out. Now you'll make a pin listen instead, so your board can sense a button and react to it.

Set a Pin as INPUT

To read a button, you first tell a pin it should receive a signal. You do that by setting its mode to INPUT inside setup().

void setup() {
  pinMode(2, INPUT);
}

A Floating Pin Lies

An INPUT pin with nothing pulling it is called floating. It picks up stray noise and flickers between HIGH and LOW all on its own.

Why Floating Hurts

A floating pin gives you random, false button readings. Your code thinks the button is pressed when nobody touched it. ⚡

Pull Resistors Fix It

A pull resistor gently ties the pin to a known voltage. That gives it a steady default reading until the button changes it.

Pull-Up vs Pull-Down

A pull-up holds the pin HIGH by default; a pull-down holds it LOW. The Arduino has handy pull-ups built right into the chip.

Use INPUT_PULLUP

Skip the extra resistor: set the mode to INPUT_PULLUP and the board enables its internal pull-up for you automatically.

void setup() {
  pinMode(2, INPUT_PULLUP);
}

The Logic Flips

With INPUT_PULLUP the pin reads HIGH when the button is released, and LOW when it is pressed. The logic is inverted on purpose.

Wire to Ground

Because the internal pull-up holds the pin HIGH, you wire the button between the pin and GND. Pressing it pulls the pin down to LOW.

Less Wiring, Fewer Bugs

INPUT_PULLUP means one less resistor on your breadboard and no floating pin. For most beginner buttons it is simply the easiest choice.

Pick the Right Mode

Reach for plain INPUT only when your circuit already supplies its own pull resistor. Otherwise INPUT_PULLUP keeps things safe and simple.

Quick Check

Think about how INPUT_PULLUP behaves on an idle button.

Recap

You learned that an INPUT pin can float and lie, and that INPUT_PULLUP fixes it: HIGH when released, LOW when pressed. Next you'll actually read that value. 👍

Häufig gestellte Fragen

Ist die Lektion „INPUT oder INPUT_PULLUP“ kostenlos?

Ja — der vollständige Text von „INPUT oder INPUT_PULLUP“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Arduino & IoT Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „INPUT oder INPUT_PULLUP“?

Erfahren Sie, warum ein offener Pin falsche Werte liefert und Pull-ups das beheben Du übst Arduino & IoT Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Arduino & IoT Academy zu starten?

Keine Vorkenntnisse erforderlich. Arduino & IoT Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.

Wie lange dauert die Lektion „INPUT oder INPUT_PULLUP“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Arduino & IoT Academy-Lektion Code schreiben und ausführen?

Ja. Jede Arduino & IoT Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. INPUT oder INPUT_PULLUP
  2. Den Tastenstatus auslesen
  3. if/else: Die LED folgt der Taste
  4. Eine Taste auf einem Breadboard anschließen
← Zurück zu Arduino & IoT Academy