Controling motor with arduino uno, pir sensor, motor driver, led screen

Hello there.

I have a project to be completed regarding rotating a 12V motor (150 rpm) motor. I want the motor rotation to be controlled by PIR sensor that detect human motion. I have the programming on PIR sensor and motor separately but I have the problem in combining them in one programme. I also want the motor controlled by a L293D motor driver. If possible, I need the circuit connection diagram too.

I really appreciate your helps. Thank you.

You have the programming for the motor and the PIR. I think they run. What is the problem running PIR and motor simultaniously? What kind of Arduino board are they connected to?

PIR sensor is on or off.
What is your purpose of using an H-bridge, and an ancient at that? Run the motor either direction based on the PIR? If it's just to switch on/off the motor or control speed in one direction a single MOSFET is simpler, smaller, cheaper and more efficient.

Show us your best attempt at combining your PIR and motor programs and explain what problems you're having. We can't help you with something we've never seen.

Steve

This is my best shot.

Coding;

int in1 = 2;
int in2 = 3;
int sensor = 8;
int led = 13;

void setup()
{
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(sensor, INPUT);
pinMode(led, OUTPUT);

digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
//digitalWrite(sensor,LOW);
digitalWrite(led,LOW);

while(millis()<13000)
{
digitalWrite(led,HIGH);
delay(50);
digitalWrite(led,LOW);
delay(50);
}
digitalWrite(led,LOW);
digitalWrite(in1,LOW);
digitalWrite(in2,HIGH);

}

void loop()
{
if(digitalRead(sensor)==HIGH)
{
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
digitalWrite(led,HIGH);
delay(2000);
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);

digitalWrite(in1,LOW);
digitalWrite(in2,HIGH);
digitalWrite(led,LOW);
delay(2000);
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);

}

}

Hi,
Welcome to the forum.

Does your best shot work?
If not what does it do?
Can you please describe what you want to happen;

  • When the PIR detects?
  • When the PIR stops detecting?

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

OPs diagram.

Tom... :slight_smile:

That program looks like it does something with an LED and a motor via an L298N when a PIR is in a particular state (after it's finished flickering the LED for some time, what's that about?).

That's all you've told us you want. So does that mean your program is working for you now?

If not we need more information about what it is doing or not doing that you want it to do...in detail please.

Steve