Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

!"#$%&' !"# !"#$%& !

"#$%&




!"#$%#& () *+,-#".,%) /0 1$.2$+,$

|u1j PIR Sensoi Nouule

0niveisity of Tasmania 2
!"#$"%#&
In this unit, you will leain about the PIR Sensoi mouule (one of the input
mouules).

The Passive Infiaieu Sensoi (PIR) uetects heat, ieau as iauiateu eneigy, of
tempeiatuies above absolute zeio.




The PIR mouule is connecteu to Aiuu-ez mainboaiu. 0nly one pin (pin numbei
S9) is connecteu to the PIR mouule. 345 .#+./". allow you to sense motion,
almost always useu to uetect whethei a human has moveu in oi out of the
sensois iange. They aie small, inexpensive, low-powei, easy to use anu uon't
weai out. Foi that ieason they aie commonly founu in appliances anu gaugets
useu in homes oi businesses. They aie often iefeiieu to as PIR, "Passive
Infiaieu", "Pyioelectiic", oi "IR motion" sensois. When the mouule uetects the
eneigy (heat), the pin gets the value "BIuB". 0theiwise, the pin gets the value
"L0W".

|u1j PIR Sensoi Nouule

0niveisity of Tasmania S
($)*%+, -,*$.# /,)#
0$#)#1%+#) 2*+.3%,+4 %+ 5%6$7$8
void begin();
Set the pin #S9 as INP0T moue anu initialize the inteinal vaiiable.

- !"#"$%&%# : none
- !"#$!% '()$" : none

int readValue();
Retuin the value(u) when the PIR mouule uetects the eneigy (heat), otheiwise
ietuin the value (u).
- !"#"$%&%# : none
- !"#$!% '()$" : 0 & 1


-79:;# /,)#4
The sample coue will uisplay the numbei "1" on the seiial monitoi when the PIR
mouule uetects the eneigy (heat).

/* ===== PIR Method =====
void begin(uint8_t pinNum);
int readValue();
======================== */

#include "PIR.h"
#define PIR_PIN 39

PIR pir;

void setup() {
pir.begin(PIR_PIN);
Serial.begin(9600);
}

void loop() {
int val = pir.readValue();
if (val ==1) {
Serial.println(val);
}
delay(1000);
}


|u1j PIR Sensoi Nouule

0niveisity of Tasmania 4
!*3:*3
veiify anu uploau the coues, then it will give an output in the Seiial Nonitoi like
below:

You might also like