I have a motor with an integrated encoder. The motor is attached to an H-bridge, and I have the encoder wired to the Arduino. I have everything connected, and I've written a program so when I run the motor, I get the number of revolution on the serial monitor. I'm wondering if there is a way to stop break the code once there is a certain number of revolutions of the motor.
if (number_of_revs > max) stop_the_motor();
@LIPX3, you need to post your program - otherwise we are just making blind guesses.
And when posting code please use the code button </>
so your code looks like thisand is easy to copy to a text editor See How to use the Forum
Hi, Welcome to the forum.
Please read the first post in any forum entitled how to use this forum. 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.
Thanks.. Tom... :)
Perhaps you need a function to actually read the encoder, so:
if (number_of_revs() > max) stop_the_motor();
Put that code in loop() so that its regularly checked. Of course some other bit of code would set it going, and you need to define number_of_revs().