Can anyone help me with programming?

Can anyone tell me the code to control a DC motor with a motion sensor? So that the motor runs about one second and preferably also runs in the other direction each time the sensor responds?

A little more information would be necessary to help.

For Example: what kind of motor, what kind of arduino what kind of sensor...

With this little information nobody can help...

Is this a homework assignment?

What have you tried? Post your attempt (in code tags) and tell us what the code actually does and how that differs from what you want the code to do.

Post a schematic of your wiring. Include all components, their values and all power supplies. Provide data sheets for things like motors, motor drivers and motion sensors.

It is not likely that anyone will write the code for you. We are here to help those that try but get stuck.

switch(sensorInput) {
  case 0: moveZero(); break;
  case 1: moveOne(); break;
// ...

@petar42 You need to tell us a lot more information. Share the code you've written so far, or what you've worked out so far.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.