Arduino · Einsteiger · Stufe 12 / 40
Interrupts and Precise Timing
React to fast external events and measure time accurately with interrupts and microsecond timing.
Einsteiger freischalten · CHF 9.90 Stufen 1–13, einmalig, kein Abo
10 Lektionen in dieser Stufe
- Polling versus Interrupts: Choosing the Right Tool
Decide when an event needs an interrupt and when polling is enough. · Lab: Miss short pulses with a slow polling loop, then explain the result. - External Interrupts with attachInterrupt
Attach a service routine to pin 2 or 3 on a chosen edge. · Lab: Count button edges with an interrupt while the main loop is deliberately slow. - volatile Variables and Short Service Routines
Share data with a service routine correctly and keep it minimal. · Lab: Remove volatile from a working sketch, observe the failure with optimisation, then restore it. - Atomic Access to Shared Multi-Byte Data
Prevent corrupted reads of values that an interrupt may change mid-read. · Lab: Provoke a torn read of a long counter and fix it by briefly disabling interrupts. - Pin-Change Interrupts on Any Pin with a Library
Extend interrupt capability beyond pins 2 and 3. · Lab: Detect changes on three buttons on arbitrary pins using a pin-change library. - Reading a Rotary Encoder Reliably
Decode quadrature signals into direction and steps without losing counts. · Lab: Adjust a value up and down with the encoder and show no skipped steps at speed. - Hardware Debouncing with an RC Filter and Schmitt Trigger
Clean a switch signal electrically before it reaches the pin. · Lab: Add an RC network and a 74HC14 stage and compare interrupt counts before and after. - Counting Pulses: Frequency and RPM Measurement
Compute rate from pulses counted in a fixed time window. · Lab: Measure the RPM of a small motor with a slot sensor or hall sensor and magnet. - Periodic Timer Interrupts with a Timer Library
Run code at an exact interval independent of loop duration. · Lab: Sample an analog input exactly every 10 ms and verify the spacing. - Microsecond Timing with micros and Pulse Measurement
Measure short durations and understand the 4 microsecond resolution on a 16 MHz board. · Lab: Measure the high time of a servo-style pulse you generate on another pin.
Abschlussprojekt
A bicycle-style speedometer with hall sensor pulse counting, rotary-encoder menu and trip distance on a display.
Teile für diese Stufe
- 1 × UNO-compatible board
- 1 × USB cable matching the board
- 1 × Solderless breadboard 830 points
- 1 × Jumper wire set male-male and male-female
- 1 × Rotary encoder module with push switch
- 1 × Hall effect sensor module
- 2 × Small magnet
- 1 × Infrared slot sensor module
- 1 × Schmitt trigger inverter 74HC14
- 5 × Ceramic capacitor 100 nanofarad
- 5 × Resistor 10 kilohm
- 2 × Tactile push button
- 1 × OLED display 0.96 inch I2C 128x64
- 1 × Small DC hobby motor 3–6 V
- 2 × LED 5 mm assorted
- 2 × Resistor 220 ohm
In jeder Lektion legst du die passenden Teile direkt in den Warenkorb. Arduino-kompatibel →
Voraussetzung: Levels 1–11: state machines, millis timing, data types and buttons.