Motion Activated motor system

BatFastard

New Member
I'm thinking about trying to incorporate some movement into a model I'm building using a motion detector system
I've found this, which looks perfect but I need to attach it to a small motor that, when activated, rotates quite slowly about 45° left and 45 ° right and then returns to the central position. This needs to run from a couple of AA batteries. If anyone can help it would be much appreciated.
10PCS-HC-SR501-Adjust-IR-Pyroelectric-Infrared-PIR-Motion-Sensor-Detector-Module.jpg
 

HughB

Active Member
I'd look at Arduino or some other small hobby microprocessor system. You can control a stepper motor quite easily, and they interface with a lot of sensors. You could probably send the output of the sensor you have there to an arduino without many issues.

Edit: In fact, someone's done the same thing (controlling an LED rather than a motor, but the principle's the same). I took the model number of the sensor you have from the name of the image, so I hope it's correct. Here you go. Here's a useful article about controlling stepper motors from Arduino.
 

opal1970

Well-Known Member
Hugh hit the nail on the head. Arduino is the best way to go and I use an arduino chip in all my models. Below are a couple comments to each of the points you will be needing...

Motion Sensor:
relatively straight forward to hook up to an arduino, really not alot a guy can do wrong at this point.

Stepper:
Using a stepper motor, you can define exactly how far the moter should turn, hence the name stepper. Depending on your motor one step can be a 1/4 or 1/8 (or even more) of a turn. Make sure you get the correct motor though, not all of them turn in both directions (unipolar or bipolar). Basically you set up the motion sensor as an input to the arduino and then just have it run your stepper code whenever there is activity.

HW / SW Compatability:
Check out the web or www.arduino.cc and make sure there is a library out there for the stepper that you are planning on buying. A library tells the arduino how to communicate with the hardware. Best is to find a library with examples that you can adapt to your project and then go out and buy that particular stepper.

Power consumption:
If you are restricted to 2 AA you might have a bit of a problem. AAs have 1.5 volts each which will give you around 3 volts... The standard Arduino UNO board needs about 3.78 volts to get off the ground if I remember correctly. You can actually go somewhat lower yet (around 3.2v, maybe a bit lower) at 16Mhz but it is out of spec so not recommended. I know there are other arduino boards that need less (Arduino Nano), but I do not remember if it is exactly 3 volts or 3. something volts. If you can hook up a 9volt battery instead your life will be a bit easier. Above all that, if you hang a stepper on the same power source, you will also likely drain your batteries quickly. there are quite a few posts in the arduino forum (www.arduino.cc) regarding minimizing the power consumtion, do a bit of searching there and in the playground and you will not be disappointed.


Hope that helps.
 
Last edited:

HughB

Active Member
You could also use a servo (as used in radio control vehicles) instead of a stepper motor - these send feedback to the microprocessor to report back on their position. Again, there's an article on how to control these from an arduino on adafruit.com as part of their overall motor control lesson.

Arduino is the best way to go and I use an arduino chip in all my models.
I agree, they're bloody brilliant little things. So much easier for lighting than building custom blinker circuits with 555 timers and things, and much more flexible. If you want to change LED brightnesses or pulse durations, or add new display modes after you've finished the model all you have to do is plug in a USB cable and tweak it.

I first used one on my Enterprise, and then used what I learned writing that code to use another one for the control circuitry for a electric brewing system, and I've just bought 3 Arduino Pro Minis (at about £5 each) for future model projects.
 

opal1970

Well-Known Member
You could also use a servo (as used in radio control vehicles) instead of a stepper motor.
Although I have to admit, I have only worked with steppers... I do not think that the servo is as exact to position as a stepper. Even after a thousand times of turning a quarter turn to the right and then and quarter to the left, a steppers starting point will always be the same.

...they're bloody brilliant little things...
I could not agree with you more. :) I have them doing all the lighting, movement, sensors even playing mp3s for sound effects (not to mention that, with the right addons, you can connect over Wireless, or WirelessLAN, bluetooth, etc)... it just does not get any better. What I love most is that even though your average arduino is not very expensive, I can still use it to bootstrap an ATmega chip and export all the functionality to it and my arduino board lives to see the next project. I am experimenting now with SMD ATmega chips (about the diameter of a pencil) now to reduce the size even more.
 

HughB

Active Member
I am experimenting now with SMD ATmega chips (about the diameter of a pencil) now to reduce the size even more.
I have horrible flashbacks of hand-soldering multi-pin SMD ICs from when I was repairing audio gear for a living briefly. Soldering the wires on the 40+ SMD LEDs I used on the JJprise was quite fiddly enough, thanks! These things at just over £4 each are small enough for me at the moment (ask me again after I've tried to cram one inside my Mk II Viper, I may have changed my tune...)
 

teslabe

Active Member
Last edited by a moderator:

BatFastard

New Member
Thanks for all the great info. Basically what I'm planning is to add this type of system to a doll so when someone passes by the PIR will move the head left and right and maybe turn on leds in the eyes.
 

HughB

Active Member
I use Pro-Minis in most of my builds for lighting and motion control, just love them, here is a short video of one controlling two StepStick stepper motor controller for my JJPrise build.
Holy crap, counter-rotating! That's awesome. Mine just go the one-way (and sound horrendous):


Edit to add: I just found your hobbytalk thread about this. Model helicopter parts, very clever! I wish I'd found that before I sealed those nacelles up...

...when someone passes by the PIR will move the head left and right and maybe turn on leds in the eyes.
That sounds utterly, utterly terrifying. Bravo!
 
Last edited by a moderator:

opal1970

Well-Known Member
Thanks for all the great info. Basically what I'm planning is to add this type of system to a doll so when someone passes by the PIR will move the head left and right and maybe turn on leds in the eyes.
sounds like Chucky. :) I am not sure where you want to go with it, but you could hook up two PIRs and have him turn his head in the direction of whichever PIR picks up motion first. Of course your code would need some sort of logic check to make sure the stepper only turns to a certain degree and nicht more in case the starting point is already turned in that direction, otherwise you may end up with the head turning too far in a given direction.

I use Pro-Minis in most of my builds for lighting and motion control, just love them, here is a short video of one controlling two StepStick stepper motor controller for my JJPrise build.
That is pretty fan-damn-tastic!
 
Top