Leggere un sensore di movimento PIR
Rilevi il movimento e regoli sensibilità e ritardo.
Leggere un sensore di movimento PIR è 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.
What a PIR Detects
A PIR sensor watches for changes in infrared heat. When a warm body like a person moves across its view, it fires.
Why It Sees Movement
PIR stands for passive infrared. It only reacts to a change in heat, so a still object soon fades from notice while motion stands out.
It Has Three Pins
A typical PIR module has three pins: VCC for power, GND for ground, and OUT for the digital signal you read.
Power It Up
Most PIR modules run on 5V. Connect VCC to 5V and GND to ground, just like any other digital sensor.
OUT Is Digital
The OUT pin gives a clean digital signal. It goes HIGH when motion is detected and LOW when the area is calm.
Set the Pin as Input
Tell the board that the OUT pin is an input so it can listen. Do this once inside setup().
pinMode(2, INPUT);Read the Motion State
Read the sensor with digitalRead. A returned HIGH means it just sensed movement nearby.
int motion = digitalRead(2);Act on Detection
Wrap the reading in an if check so your code does something, like light an LED, only when motion is HIGH.
if (motion == HIGH) {
// movement detected
}Tune the Delay Trim
The on-board delay trimpot sets how long OUT stays HIGH after motion. Turn it to hold the signal longer or shorter.
Tune the Sensitivity Trim
The second trimpot adjusts sensitivity, the range at which motion triggers. Lower it to ignore far-off movement.
Let It Warm Up
Give a PIR up to a minute to calibrate after power-on. Early readings can be jittery until it settles.
Quick Check
What does a PIR sensor actually respond to?
Recap: Sensing Motion
You wired a PIR with VCC, GND, and OUT, read it with digitalRead, and tuned the delay and sensitivity trimpots.
Domande Frequenti
La lezione «Leggere un sensore di movimento PIR» è gratuita?
Sì — il testo completo di «Leggere un sensore di movimento PIR» è 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 «Leggere un sensore di movimento PIR»?
Rilevi il movimento e regoli sensibilità e ritardo. 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 «Leggere un sensore di movimento PIR»?
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
- Leggere un sensore di movimento PIR
- Misurare la luce con un LDR
- Impostare una soglia di luminosità
- Luce notturna automatica