hi
for an upcoming scouting project i want to control the speed of an 12v motor with an Mosfet based on the speed of an ir speed sensor (image attached).
how would i go about in coding this?
greetings jim vogelzang Netherlands
hi
for an upcoming scouting project i want to control the speed of an 12v motor with an Mosfet based on the speed of an ir speed sensor (image attached).
how would i go about in coding this?
greetings jim vogelzang Netherlands
I don't get it. You want to control the speed of a motor based on the speed of another motor? Or is it the same motor?
Perhaps what you mean is that you want the motor to achieve a target RPM. You want to use an IR speed sensor to measure the actual RPM achieved. From that you can then adjust the signal to the MOSFET up or down to match the actual RPM to the target RPM?
If that is correct, I guess you would use a PWM Arduino pin to control the MOSFET with the analogWrite() function. You could use the pulseIn() fuction to measure the time that the IR signal is HIGH and the time it is LOW. Knowing the number of HIGH/LOW periods in a rotation, you can calculate the actual RPM. Then you use that as feedback to adjust the PWM signal. There is a commonly used Arduino library for that but I can't remember its name. EDIT: I remembered its called the PID library.
It sounds very doable. From What I see the speed sensor is the feed back sensor to control the motor sensor. This is a best guess with all the information provided. Why not start by defining the problem with specifications including a flow chart and schematic. Define what is the expected outcome. Purchase the Arduino cookbook and read it, this will give you some basics. also use the online tutorials and videos available, there are many good ones on this web site. At this point you will be able to define the problem and may have already solved it.
sorry for the bad description, i was in a hurry. so the basic idea i wanted to do is control the speed of a dc 12v motor based on the output of a ir speed sensor. the image of the speed sensor was just an example to show you the sensor
so this needs to happen in the code. the ir speed sensor reads the speed of something turning.
then outputs this to the Arduino and based on that controls the speed of the 12v dc motor.
so when the speed that the ir sensor reads goes the speed of the 12v motor also goes up
the speed sensor is attached to an wooden wheel that you turn by hand
this code needs to do exactly the same as an 12v hand crank generator connected directly to a 12v motor
i want to do it this way because i want to have an 12v battery as a power source
image attached is my setup
but i dont know how to write the code.
but i dont know how to write the code.
Do you want us to write the code for you, or do you want to write the code yourself?
hi sorry for the late response,
i made a schematic (the best i could never done it before)
the image of the component is the IR speed sensor I’ll be using. it pin goes either high or low depending if something is blocking its beam.
between that speed sensor will be a 3d printed disk with a number of slots like in the pictures attached before.
i am able to change the variables in the code like number of slots i am going to use in that disk and sorts.
but the whole code looks like a serious challenge to me so
if it isn’t to much work for you than can you please wire the code for me
(and just add command where I need to change variables)
if you need any additional info please tell me

Please think about EXACTLY you want to control the motor speed. So far, you just write about that happening, but no details.
Paul

if it isn't to much work for you than can you please wire the code for me
I wondered if that was what you were asking. Generally we don't write code for you, but we will help you to write your own code. If you want to pay for code to be written, there is a forum section where you can offer how much you can pay and someone might agree to write it for you.