کمی طول کشید تا شروع کنم، اما توانستم 2 حسگر مادون قرمز PIR را با یک آردوینو سیم کشی کنم تا حرکت را در سمت چپ یا راست حس کنم . در نتیجه یک LED برای نمایش هر سنسور PIR فعال میشود، سپس من نیز به یک سروو اضافه کردم تا کنترل شود - بنابراین وقتی توسط سنسور چپ فعال میشود و غیره به سمت چپ میچرخد.
ابتدا نگاهی به آموزش قبلی من - مدار آشکارساز حرکت آردوینو PIR بیندازید . اکنون می خواهیم از 2 مورد از آنها استفاده کنیم و این تفاوت چندانی با استفاده از یکی از آنها ندارد. با این حال، این تنها اولین تلاش است، بنابراین من هیچ چیزی را به درستی کالیبره نکردهام، برای مثال، نمیتوانیم سرعت یا جهت واقعی حرکت را مشخص کنیم، زیرا این سنسورها آنقدر دقیق نیستند و طیف وسیعی از تشخیص را دارند. اما هی، این یک شروع است!
قطعات مدار سنسور حرکت آردوینو PIR
مقاومت 2x 220 اهم (قرمز، قرمز، قهوه ای، طلایی)
2x مقاومت 10K اهم (قهوه ای، مشکی، نارنجی، طلایی)
2x سنسور PIR
1x سروو (نیازی به منبع تغذیه بیش از 5 ولت ندارد)
2x LED
Arduino Deumilanove با
تخته نان ATMEGA328 / تخته نمونه سازی
سیم های جامپر/کانکتور منبع تغذیه 9 ولت DC
اختیاری یا از برق USB برای آردوینو استفاده کنید اگر از PIR مشابه من استفاده می کنید به آهن لحیم کاری و لحیم کاری نیز نیاز خواهید داشت. نوعی چسب موقت برای نگه داشتن سنسورها در جای خود.
مدار آشکارساز حرکت مادون قرمز آردوینو
بنابراین خواهید دید که سیم آن واقعاً زیاد است. PIR هایی که من روی سیم ها و روی پایه خروجی آنها لحیم کرده ام یک مقاومت 10K اهم برای هر حرکت بین آنها و ریل مثبت روی تخته نان وجود دارد. ال ای دی ها همان چیدمان آموزش های اولیه چشمک زدن هستند، مقاومت 220 اهم بین پایه مثبت (طولانی تر) و پین آردوینو.
کد آردوینو سنسور حرکت PIR
این خیلی بد نیست اساساً ما 2 حسگر را تنظیم میکنیم و چند دستور if داریم که بر اساس روشن یا خاموش شدن آنها کار خرابی انجام میدهند، بنابراین اساساً مانند چند سوئیچ با آنها رفتار میشود.
/* LUCKYLARRY.CO.UK - 2 3pin PIR sensors to track basic motion. We have 1 sensor for left, 1 for right. The left sensor is triggered, the LED for the left comes on and the servo moves until no motion is detected. The same happens if the right sensor is triggered. If both sensors detect motion then its likely the object may be between the 2 but given the field of detection its not going to be precice. Enjoy! */ #include // Include servo library, you can get it from http://www.arduino.cc/playground/ComponentLib/Servo Servo myservo; // Create a servo object int pos = 0; // Variable to store the servo position in degrees int pinPIRleft = 4; // left infrared sensor, digital pin 4 int pinLEDleft = 8; // left LED, digital pin 8 int pinPIRright = 2; // right sensor, digital pin 2 int pinLEDright = 10; // right LED, digital pin 10 void setup() { pinMode(pinLEDleft, OUTPUT); // set LEDs as outputs pinMode(pinLEDright, OUTPUT); pinMode(pinPIRleft, INPUT); // set sensors as inputs pinMode(pinPIRright, INPUT); myservo.attach(9); // set the servo to digital pin 9 }
برای جزئیات بیشتر: آردوینو – (بسیار) ردیابی حرکت پایه با 2 سنسور PIR
در ادامه، متن انگلیسی این مطلب را میتوانید مشاهده نمایید:
Took me a little while to get started but I’ve managed to wire 2 PIR infrared sensors with an Arduino to sense motion either on the left or on the right side. The result will trigger an LED to represent each PIR sensor then I also added in a servo to be controlled – so it turns left when triggered by the left sensor and so on.
First have a look at my previous tutorial – Arduino PIR motion detector circuit. Now we’re going to use 2 of them and this isn’t that different from just using one of them. However this is only a first attempt so I’ve not calibrated anything properly, for instance we can’t ascertain velocity or true direction of movement because these sensors aren’t that precise and have a wide range of detection. But hey, it’s a start!
Arduino PIR Motion Sensor Circuit Parts
2x 220 Ohm resistor (Red, Red, Brown, Gold)
2x 10K Ohm resistor (Brown, Black, Orange, Gold)
2x PIR sensor
1x Servo (has to need no more than 5v supply)
2x LED
Arduino Deumilanove w/ ATMEGA328
Breadboard / Prototyping board
Jumper/ Connector wires
Optional 9V DC power supply or use the USB power for the Arduino
You will also need a soldering iron and solder if you use the same PIR as myself.
Some sort of temporary adhesive to hold the sensors in place.