Programming help needed. Will pay $ fast cash $.

New to the world of Arduino.

Project details:

  1. Arduino nano
  2. PiR sensor
  3. 12vdc mini gear motor

Functions: (3)

PiR triggers the gear motor to move forward 0-60 seconds - stop
PiR triggers the gear motor to move in reverse 0-60 seconds - stop
0-60 second pause between each trigger.

Essentially, the PiR loops the motor back & forth, (forward-reverse) after each trigger.

Anybody interested in a new challenge ?

Anybody interested in a new challenge ?

What is the challenge? Wiring a PIR sensor is easy. Reading the sensor is easy. Determining that the sensor has, or has not, changed state is easy.

Setting the motor shield direction pin is easy. Running the motor at some speed for some time is easy.

What does 0-60 seconds mean? Pick some random number and delay() that number of seconds while the motor runs? At what speed?

Oh, I see what the challenge is. It's guessing what you mean by the vague requirements.

Hi bingoo,

Can you provide the forum a little more information?

  1. How are you controlling the motor? Are you using a shield like PaulS wonders?

  2. One PIR or two (front/back)?

  3. Are you designing a robot to attack a cat? (If so, you may want to include a laser pointer.)

Pat

Something like:

enum State {
  STOPPED,
  MOVING,
  WAITING
} state = STOPPED;

boolean directionForward = true;

uint32_t moveStartMs;

void setup() {
  // put stuff here to set up the PIR and motor
}

void loop() {
  switch (state) {
    case STOPPED:
      if(pirDetected()) {
        if(directionForward) {
          startMotorForward();
        }
        else {
          startMotorReverse();
        }
      }
      moveStartMs = millis();
      state = MOVING;
      break;

    case MOVING:
      if(millis()-moveStartMs >= 60000L) {
        stopMotor();
        directionForward = !directionForward;   
        state = WAITING;   
      }
      break;

    case WAITING:
      if(millis()-moveStartMs >= 120000L) {
        state = STOPPED;   
      }
      break;
  }
}

boolean pirDetected() {
  // you need to write this bit
  return false;
}

void startMotorForward() {
  // write this bit
}

void startMotorReverse() {
  // write this bit
}

void stopMotor() {
  // write this bit
}

@PaulS

If the challenge was easy it won't be so challenging. Who said anything about a motor speed..variable. Uhmm....apparently not a project requirement. Asking the right question is part of the challenge.

Who said anything about a motor speed..variable.

My point was that you failed to say anything about the speed of the motor.

Uhmm....apparently not a project requirement.

Really? The speed of the motor is not important?

Asking the right question is part of the challenge.

I'm going to pass, then. Asking clarifying questions is one thing. Asking basic "It looks like you failed to say anything about xxxx; is that intentional?" questions should not be necessary.

Bingoo:
Uhmm....apparently not a project requirement.

Apparently? I'm getting the impression that this is a school project. Are you able to tell us what institution you are attending? The lecturer/class name would be handy, too. Oh, and could you let us know your student id number? No need for real names - just the id number should do.