Download Print this page

Velleman VMA314 User Manual page 4

Pir motion sensor for arduino

Advertisement

7.
Connection
8.
Example
//Code Begin
const int SensorSignal = 2; // define integer SensorSignal with value 2 , this is the signal output
(S, or OUT) from your sensor (can be any sensor)
const int ledPin = 13; // define integer ledPin with value 13
int sensorValue = 0;
void setup() {
pinMode(SensorSignal, INPUT); // declare digital pin 2 as input, this is where you connect the S
output from your sensor, this can be any digital pin
pinMode(ledPin, OUTPUT); // declare digital pin 13 as output, this digital pin is also connected to
the Yellow LED on your VMA100 board
}
void loop(){
sensorValue = digitalRead(SensorSignal); // read the value of pin 2, should be high or low
if (sensorValue == HIGH) { digitalWrite(ledPin, HIGH); // set pin 13 (ledPin) according to the
value on pin 2
}
else { digitalWrite(ledPin, LOW);
}
}
//code End
V. 02 – 29/05/2018
VMA314
4
©Velleman nv

Advertisement

loading