Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



how to add two PIR ...
 
Share:
Notifications
Clear all

[Solved] how to add two PIR sensor. stair project

6 Posts
2 Users
0 Reactions
5,155 Views
(@luckykang)
Active Member
Joined: 8 years ago
Posts: 4
Topic starter  

hi guys is anyone can help me i jst wanna add two pir sensor with these codes top and bottom im bit confuse with wiring and coding is anyone knows how to do it thx  


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
 

Hi Luckychan,

thank for starting a forum topic.
I'd start with a simple PIR project first, and with just one PIR. For example this one.
Next step; replicate that simple project by using 2 PIRs.

You'd have to add the second PIR to your code, for example with 1 PIR:

int led = 13;                // the pin that the LED is attached to
int sensor = 2; // the pin that the PIR sensor is attached to
int state = LOW; // by default, no motion detected
int val = 0; // variable to store the sensor status (value)
void setup() {
  pinMode(led, OUTPUT); // initialize LED as an output
  pinMode(sensor, INPUT); // initialize sensor as an input
  Serial.begin(9600); // initialize serial
}

and with 2 PIRs:

int led = 13;                // the pin that the LED is attached to
int sensor1 = 2; // the pin that the first PIR sensor is attached to
int sensor2 = 3; // the pin that the second PIR sensor is attached to
int state = LOW; // by default, no motion detected
int val = 0; // variable to store the sensor status (value)
void setup() {
  pinMode(led, OUTPUT); // initalize LED as an output
  pinMode(sensor1, INPUT); // initialize sensor as an input
  pinMode(sensor2, INPUT); // initialize sensor as an input
  Serial.begin(9600); // initialize serial
}

Now you have to incorporate that in you void loop(), but I'm not quite sure what your project is or what it should do.


   
ReplyQuote
(@luckykang)
Active Member
Joined: 8 years ago
Posts: 4
Topic starter  

The project  i m working on is stair project one PIR sensor bottom stair and one top so when bottom sensor activate the light start from bottom to top when top sensor activate the light start top to bottom and also how to do the wiring also thx


   
ReplyQuote
(@luckykang)
Active Member
Joined: 8 years ago
Posts: 4
Topic starter  

hey hans can you tell me that the led strip effects codes will work on this led strip led photo attached thx


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
 

Hey Luckykang,

I have never work with those, since that one seems to be a 12V model.
Doesn't mean it will not work, just that you need a 12V power supply for the main power of the LED strip (not the Arduino!).

They somehow they look like the older LED strips like the WS2801, but since there is no model/type printed anywhere, it would not know. The only way to find out is by just testing. Keep in mind +12V voor de LED strip, but +5V for the Arduino. Also; the calculation to determine how "heavy" the power supply would be, will be different as well. If you calculate the Amps needed for 5V, the for 12V your need about 1/2 of the amps.

Also keep in mind that this strip seems to use a Data and Clock signal, unlike the WS2811/WS2812 which do not use a Clock signal.
And the clock signal might or might not be supported by the library you'll be using...

I did find this post in case you're using FastLED: Arduino Website Topic: Cannot get WS2801 LED's to work
I did find something at GitHub in case you're using NeoPixel: Example library for driving Adafruit WS2801 pixels

Please keep in mind; I have never used these LEDs, I intentionally picked the WS2811/WS2812 for my projects to keep things simple ... 

Hope this helps!


   
ReplyQuote
(@luckykang)
Active Member
Joined: 8 years ago
Posts: 4
Topic starter  

The project i m working on is stair project one PIR sensor bottom stair and one top so when bottom sensor activate the light start from bottom to top when top sensor activate the light start top to bottom and also how to do the wiring also thx

Similar to this video

https://www.youtube.com/watch?v=lNxgYWHewzg


   
ReplyQuote
Share: