trigger a project with PIR sensor/timer (Solved)

Hi, I’m fairly new here. I made a project with a 4-relay shield, operating 3 DC motors and I got that working. I even worked out how to run the program only once. I did this because I want to make it run once (or max 4 times) when a Passive Infra Red sensor with timer has been triggered.

When someone passes by, butterflies will flutter about…

How can I connect the 3 pins of the PIR/Timer to my board and/or shield (which pins for Vcc,Gnd and Signal 5V?) and how do I add the sensor into the code?

This is my code:

#define PIN 2,8,10,
void setup () {

// initialize the digital pins as an output.

pinMode(2, OUTPUT);
pinMode(8, OUTPUT);
pinMode(10, OUTPUT);
digitalWrite(2, HIGH); // Turns ON Relay on digital pin 4
delay(300); // size of drop in ms
digitalWrite(2, LOW); // Turns OFF Relay on digital pin 4
delay(600); // time between 1st and 2nd drops
digitalWrite(8, HIGH); // Turns ON Relay on digital pin 6
delay(500); // size of drop in ms
digitalWrite(8, LOW);
delay(600); // Turns OFF Relay on digital pin 6
digitalWrite(10, HIGH); // Turns ON Relay on digital pin 4
delay(400);
digitalWrite(10, LOW);
}

void loop(){

}

A data sheet for the sensor would be more useful than a picture. You do not say which Arduino board that you are using (is it a 5V or 3.3V board?). Please read the how to use the forum stickies. They will explain how to properly format and post code and provide hints on what we need to know to be able to help you.

The Board is Arduino Uno
The shield DFRobot 4-relay
The Sensor HC-SR501 (see attachment)

I would really apreciate it when this part of my project gets to work too. It’s a experience/discovery panel for a daycare center for handycapped children, featuring this part, which sets some butterflies fluttering (wings made of tullip-leaves)

I also used WS2812 LED strip and got that part working allright (it loops, no sensor) showing juices running up a tree. This is propelled by a Arduino Uno clone

The other feature is buttons strewn over the panel producing bird sounds from a readymade recording kit with 5 x 60 seconds memories

I’ll post a Youtube link when it’s ready

Here are a couple of links to pages that I found on setting up the sensor and connecting to an Uno.

http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-hc-sr501-motion-sensor-tutorial/

http://howtomechatronics.com/tutorials/arduino/how-pir-sensor-works-and-how-to-use-it-with-arduino/

Here is a simple sketch using your code to try the sensor. Connect the sensor output to pin 3. You may need to put a delay in setup() to wait for the sensor to initialize. The sensor can output false pulses during its initialization (see data sheet).

const byte pirPin = 3;

void setup ()
{
  // initialize the digital pins as an output.
  pinMode(2, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(10, OUTPUT);

}

void loop()
{
  if(digitalRead(pirPin) == HIGH) // if there is motion
  {
  digitalWrite(2, HIGH);    // Turns ON Relay on digital pin 2
  delay(300);               // size of drop in ms
  digitalWrite(2, LOW);     // Turns OFF Relay on digital pin 2
  delay(600);              // time between 1st and 2nd drops
  digitalWrite(8, HIGH);    // Turns ON Relay on digital pin 8
  delay(500);               // size of drop in ms
  digitalWrite(8, LOW);
  delay(600);                // Turns OFF Relay on digital pin 8
  digitalWrite(10, HIGH);    // Turns ON Relay on digital pin 10
  delay(400);
  digitalWrite(10, LOW);
  delay(30000);               // delay 30 secnds before testing again, change as desired
  }
}

Dear groundFungus, just tried and it worx! I can now adjust times, intervals etc and mount this whole part on the panel. Thanx a BIG lot!! video follows as promised Gerrit