How to run an engine according to a distance sensor

Hello, for my final project, i have to make a connection between an engine and a distance sensor. Actually, i'm in a simulation and i have a problem, i don't know how to connect the engine and the distance sensor. Can you help me please?

Yet another "final project" from a completely clueless individual. Too late.

There are many types of motors and distance sensors. Can you give us more information on those parts. Data sheets for them would be best.

For the motor, you will need a driver as an Arduino can control a motor, but does not have the current capability to drive a motor.

A more detailed description of your project will help, too.

Real the how to use this forum sticky for some advice on how to get the most from the forum.

In a simulation? Simulated sensor and motor or simulated you? Are you trolling?

ArnoDuBinks:
have to make a connection between an engine and a distance sensor.

Remember too that although conceptually you may consider there to be a connection, the Arduino goes in the middle.

So you need to get the Arduino to:

  • Read the sensor first
  • Then ponder that reading by comparing to say some safety threshold and decide what action to take, if any
  • Lastly convert that action into some outputs which will control the motor/s

So a useful approach might be:

  • Get the sensor working by itself, displaying results on monitor
  • Get a motor working by itself, perhaps with speed and direction of rotation hard-coded in the sketch
  • Then get the other motors (if any) doing the same.. I'm assuming you have some kind of car robot thing?
  • Design the logic that converts tye sensor readings into motor actions
  • Lastly write the final sketch that ties it all together

My main point is, don't try to write a sketch to control a motor with a sensor, without first getting them to work by themselves. My opinion, anyway.

arduin_ologist:
Remember too that although conceptually you may consider there to be a connection, the Arduino goes in the middle.

So you need to get the Arduino to:

  • Read the sensor first
  • Then ponder that reading by comparing to say some safety threshold and decide what action to take, if any
  • Lastly convert that action into some outputs which will control the motor/s

So a useful approach might be:

  • Get the sensor working by itself, displaying results on monitor
  • Get a motor working by itself, perhaps with speed and direction of rotation hard-coded in the sketch
  • Then get the other motors (if any) doing the same.. I'm assuming you have some kind of car robot thing?
  • Design the logic that converts tye sensor readings into motor actions
  • Lastly write the final sketch that ties it all together

My main point is, don't try to write a sketch to control a motor with a sensor, without first getting them to work by themselves. My opinion, anyway.

First, ty for your help but everything has already been studied. I do my project simulation on Proteus 8, excellent project simulator btw but i have a problem.

Here, you can find my images project :
Cabling : https://www.noelshack.com/2019-06-2-1549353760-capture.jpg
Coding : https://www.noelshack.com/2019-06-2-1549353765-capture2.jpg
https://www.noelshack.com/2019-06-2-1549353969-capture3.jpg

Problem is my sensor captor don't wants to stop my second engine when the voltmeter who changes in function of the distance sensor reach the value of 0.41. Do you have an idea?

jremington:
Yet another "final project" from a completely clueless individual. Too late.

Okay my project is for the 10 June so it's not "too late" like you things. Man, idk why you post here if it's not to help me...

ArnoDuBinks:
First, ty for your help but everything has already been studied. I do my project simulation on Proteus 8, excellent project simulator btw but i have a problem.

Do your tests with a real Arduino, a real sensor and a real motor.

How do we know whether the problem is inside Proteus?

Got to a Proteus Forum for help with Proteus.

...R

PS ... if you are a student then ask your teachers for help - that's what they are paid for.

Robin2:
Do your tests with a real Arduino, a real sensor and a real motor.

How do we know whether the problem is inside Proteus?

Got to a Proteus Forum for help with Proteus.

...R

PS ... if you are a student then ask your teachers for help - that's what they are paid for.

Yeah thanks you for your answer but before testing with a real Arduino, we have to make a simulation on Proteus. Idk if the problem is inside Proteus or not but i have to make this simulation. I have already search Proteus forum but i don't found anything. Moreover, there is 1 teacher for 30 students so... i prefer asks pros in a Arduino forum

Hi,
If you are having trouble loading into Proteus, and you were taught how to use Proteus at your college/uni, then go and ask your lecturer/instructor.

Tom... :slight_smile:

ArnoDuBinks:
Yeah thanks you for your answer but before testing with a real Arduino, we have to make a simulation on Proteus. Idk if the problem is inside Proteus or not but i have to make this simulation. I have already search Proteus forum but i don't found anything. Moreover, there is 1 teacher for 30 students so... i prefer asks pros in a Arduino forum

My advice is to get it working on a real Arduino and then build the simulation.

If the real thing works and the simulation does not then you know there is something wrong with the simulation.

If you start with a working simulation that is no guarantee that the real thing will work.

Simulations can be very helpful and time-saving. But you need to understand the thing you are trying to simulate so that you don't make silly mistakes setting up the simulation.

...R

If you want help with your code, post the code here. We don't much like to download pictures of code.

Read the how to use this forum sticky to see how to post code.

One hint: the map() function does not work with floats.

Okay, finally, I finish what I want to do but now I have another problem, i have to say in Arduino language "during 5seconds" idk how to say that

ArnoDuBinks:
Okay, finally, I finish what I want to do but now I have another problem, i have to say in Arduino language "during 5seconds" idk how to say that

Have a look at how millis() is used to manage timing in Several Things at a Time.

And see Using millis() for timing. A beginners guide if you need more explanation.

As you have not told us anything about what is to happen during your 5 seconds I can't be more specific.

And, as has already been suggested, if you really want help post the program that represents your best attempt and tell us in detail what it actually does and what you want it to do that is different. And please use the code button </> when posting code
codeButton.png

...R