Help raspberry pi/arduino with a pir sensor, needed for a newbie!

Thread Starter

Chopzilla

Joined Jan 7, 2023
7
Hi everyone, i'm working on a project and i really have no idea what im doing past a couple of points.

The idea is to make butterfly wings flap using stepper motors, drivers and a rapberry pi/arduino with a pir sensor as the on/off. Where i'm struggling is i have no idea on the components i need to make this happen.

Is there anyone here willing to help me?
 

WBahn

Joined Mar 31, 2012
29,978
There are kits that do just this. They aren't too expensive, so you might get one of those and see how they did it and then adapt it to suit your particular interests.
 

Thread Starter

Chopzilla

Joined Jan 7, 2023
7
There are kits that do just this. They aren't too expensive, so you might get one of those and see how they did it and then adapt it to suit your particular interests.
Would that just be something that uses pulse width modulation?
 

BobTPH

Joined Jun 5, 2013
8,813
A DC motor + a mechanical linkage tied to the rim of a wheel would be the easiest way. No microcontroller needed. Think of windshield wipers, that is how they work.
 

KeithWalker

Joined Jul 10, 2017
3,063
Your question jumped directly directly to a hardware solution without giving us any other information. If you would like us to help you to achieve your goal, please give us the basic requirements such as budget, size, weight, environment, orientation, angle and speed of wing motion, range of sensors, etc. Then we can discuss what is available and find you a workable solution.
 

Thread Starter

Chopzilla

Joined Jan 7, 2023
7
A DC motor + a mechanical linkage tied to the rim if a wheel would be the easiest way. No microcontroller needed. Think of windshield wipers, that is how they work.
this was the original plan but the space it needs to fit in is very very small and the tiny stepper motors provided a smaller profile overall
 

Thread Starter

Chopzilla

Joined Jan 7, 2023
7
Your question jumped directly directly to a hardware solution without giving us any other information. If you would like us to help you to achieve your goal, please give us the basic requirements such as budget, size, weight, environment, orientation, angle and speed of wing motion, range of sensors, etc. Then we can discuss what is available and find you a workable solution.
okay, budget isnt an issue right now as i dont see components costing thousands, the butterflies will be sitting on human realistic rib bones so most of the components can be hidden in them, best idea i can give you on size is as small as possible, environment will be indoors, i can make the motor operation work in either orientation (horizontal, vertical), angle will be through 90 degrees (i think) but im not sure how possible this will be.

I'm sorry if this is vague but its still an idea in its infancy and this has been the stumbling block.

Below is a rough starting code if that helps give you some idea? Please dont give to much thought to the code, i had an ai write it.

Code:
 # Import the necessary libraries import time from AccelStepper import AccelStepper # Set the pins for the stepper motor and PIR motion detector step_pin = 3 direction_pin = 4 pir_pin = 2 # Set the flapping frequency flapping_frequency = 2 # flaps per second # Calculate the delay between steps step_delay = 1.0 / (flapping_frequency * 200) # 200 steps per revolution # Set up the AccelStepper object stepper = AccelStepper(1, step_pin, direction_pin) stepper.setMaxSpeed(200) stepper.setAcceleration(50) while True:  # Wait for motion to be detected  while not digitalRead(pir_pin):    time.sleep(0.1)    # Flap the wings for 10 seconds  start_time = time.time()  while time.time() - start_time < 10:    # Take 200 steps to complete one revolution    for i in range(200):      stepper.setSpeed(200)      stepper.runSpeed()      time.sleep(step_delay)    # Pause for a moment    time.sleep(0.5) [CODE]
 

MrChips

Joined Oct 2, 2009
30,711
The idea is to make butterfly wings flap using stepper motors, drivers and a rapberry pi/arduino with a pir sensor as the on/off. Where i'm struggling is i have no idea on the components i need to make this happen.
I begin, is this thing actually supposed to fly?
If so, you need to consider total weight, power management, etc.
If you want to minimize weight then I would not choose raspberry pi nor arduino.
Also, stepper motors would be a off the list.
 

Thread Starter

Chopzilla

Joined Jan 7, 2023
7
I begin, is this thing actually supposed to fly?
If so, you need to consider total weight, power management, etc.
If you want to minimize weight then I would not choose raspberry pi nor arduino.
Also, stepper motors would be a off the list.
No, it's not meant to fly, apart from a breathing led light (I know how to do this) and the wings just moving up and down it's static.
 

MrChips

Joined Oct 2, 2009
30,711
Ok. Don't use stepper motors. Use a small hobby DC motor that rotate at a fixed speed in one direction.
Use a mechanical linkage to make the wings flap.
 

djsfantasi

Joined Apr 11, 2010
9,156
Using Nitinol to make a heat activated spring is the smallest way to make butterfly wings flap. It is a common way of making commercial animated butterflies.
 

Thread Starter

Chopzilla

Joined Jan 7, 2023
7
Here’s a commercial Nitinol butterfly.

You can make your own easily by buying the Nitinol wire .
I have briefly looked at this but it still leaves me with my original problem of I don't know what I'm doing or need to make any of these things work and past wiring up some LEDs with an on/off switch I have no knowledge of how to do this. It doesn't matter how much I read or watch, I just simply don't understand it.
 

djsfantasi

Joined Apr 11, 2010
9,156
You can use a pre-made PIR Module as your sensor. Besides power to the module you need two connections to its relay. With the commercial Nitinol butterfly in the link above, you would cut one of its power supply wires in two and connect them to the Common and NO (Normally Open) connections of the relay. Then when someone comes near, the butterfly will flap its wings. That’s it: 4 wires and 2 modules. There is one gotcha. Depending on if the butterfly adapter is the correct voltage for the PIR module, you may need a second power supply. But still 4 wires and 2 modules.
 

KeithWalker

Joined Jul 10, 2017
3,063
You don't need a microcontroller or a stepper motor for this project. There are small geared 60RPM motors available for low DC voltages that could be driven directly by a PIR switch. Check out both components on AliExpress.
The mechanical linkages are very rudimentary as you can see on the pictures below of a little 6" flying butterfly that I made:
Butterfly 002.jpgButterfly 001.jpg
 

djsfantasi

Joined Apr 11, 2010
9,156
@KeithWalker
Great project. But it seems to me the TS ability is at the wiring diagram phase and even a schematic would be over his / her head. I’d have done so in my post, but don’t even have a pen and paper in my hospital bed (slight temporary inconvenience)
 

Thread Starter

Chopzilla

Joined Jan 7, 2023
7
@KeithWalker
Great project. But it seems to me the TS ability is at the wiring diagram phase and even a schematic would be over his / her head. I’d have done so in my post, but don’t even have a pen and paper in my hospital bed (slight temporary inconvenience)
Not entirely true. I've been using wiring diagrams and reading architectural as well as m&e blueprints for the past 16 years, just because I don't understand how a thing works doesn't mean I can't follow a plan...
 

djsfantasi

Joined Apr 11, 2010
9,156
Not entirely true. I've been using wiring diagrams and reading architectural as well as m&e blueprints for the past 16 years, just because I don't understand how a thing works doesn't mean I can't follow a plan...
I apologize for my assumptions. How very rude of me.
 

KeithWalker

Joined Jul 10, 2017
3,063
Here is what you need:

12VDC PIR sensor switch module:
https://www.aliexpress.com/item/1005002097669527.html?spm=a2g0o.productlist.main.7.16a45f54e3tqMU&algo_pvid=6903ab12-8024-40c5-a3d4-d274d6d011cb&algo_exp_id=6903ab12-8024-40c5-a3d4-d274d6d011cb-3&pdp_ext_f={"sku_id":"12000025797677433"}&pdp_npi=2@dis!CAD!4.1!3.69!!!!!@211be17616731958307894334d0735!12000025797677433!sea&curPageLogUid=si6ze8coeL9L

12VDC miniature motor 60RPM:
https://www.aliexpress.com/item/329...02301080858139814169708424900013451245_2https:

Let us know if you are not sure how to wire them together. Make sure that you put a reverse diode, 1N4000 or similar across the motor terminals to protect the switch from interference from the motor.
You didn't mention what you will be powering this with. You will need a battery or DC power supply that can give you 12VDC at 2A.
 
Top