Endpreise in CHF – Versand inklusive Schweizer Unternehmen · 076 792 63 50 (WhatsApp/SMS)
Kurse › Raspberry Pi › Stufe 7
Raspberry Pi · Einsteiger · Stufe 7 / 40

Buttons, Buzzers and Events

Read switches and simple digital sensors reliably and write event-driven GPIO programs.

Einsteiger freischalten · CHF 9.90 Stufen 1–13, einmalig, kein Abo

10 Lektionen in dieser Stufe

  1. Reading a Push Button with Pull-Up and Pull-Down Resistors
    Explain a floating input and fix it with internal or external pulls. · Lab: Wire a button to GPIO and ground, read it with Button and observe what happens with pull_up=None and no resistor.
  2. Polling Versus Events: when_pressed Callbacks
    Replace a busy loop with callbacks that run when something happens. · Lab: Write the same button-toggles-LED program as a polling loop and as callbacks, and compare CPU use.
  3. Taming Switch Bounce
    Recognise contact bounce and remove it with bounce_time. · Lab: Count presses with and without debouncing and record how many false counts you get.
  4. Long Presses, Double Presses and Hold Timers
    Give one button several functions using hold_time and timing logic. · Lab: Make a short press toggle an LED and a two-second hold switch everything off.
  5. Making Sound with Active and Passive Buzzers
    Drive both buzzer types and play notes with TonalBuzzer. · Lab: Beep an active buzzer, then play a short scale on a passive one.
  6. Detecting Movement with a PIR Sensor
    Wire a PIR module and tune its sensitivity and hold time. · Lab: Light an LED on motion using MotionSensor and adjust both trimmers until it behaves.
  7. Door and Window Sensing with a Reed Switch
    Use a magnetic contact as a normally-closed alarm input. · Lab: Log open and close events of a box lid with timestamps.
  8. Connecting Devices in Code with source and values
    Link inputs to outputs declaratively using gpiozero's source chain. · Lab: Make an LED follow a button, then invert and combine two inputs with source tools.
  9. Keeping Scripts Alive and Exiting Cleanly
    Use pause, handle Ctrl+C and release pins on exit. · Lab: Add a clean shutdown path to an earlier script so no LED is left on.
  10. Building a Reaction-Time Game
    Combine random delays, timing and input events into a complete program. · Lab: Build a two-player game that lights an LED after a random wait and names the faster player.

Abschlussprojekt

A desk alarm that is armed and disarmed with a long button press, watches a PIR sensor and a door contact, and sounds a buzzer with a status LED.

Teile für diese Stufe

  • 1 × Raspberry Pi 5 or Pi 4 set from Level 1
  • 1 × Breadboard and jumper wire set from Level 6
  • 4 × Tactile push button 12 mm
  • 1 × Active buzzer module 3.3 V
  • 1 × Passive piezo buzzer
  • 1 × PIR motion sensor module
  • 1 × Magnetic reed switch with magnet
  • 1 × LED and resistor assortment from Level 6

In jeder Lektion legst du die passenden Teile direkt in den Warenkorb. Raspberry Pi →

Voraussetzung: Level 6: breadboard wiring, resistor calculation and gpiozero outputs.

🔒 Sichere Zahlung · 3D Secure 🔐 SSL-verschlüsselt 🚚 Versand in die ganze Schweiz 🇨🇭 Schweizer Unternehmen