Just to let you know I am trying to build a self balancing two wheeled robot. I am using two pololu 37mm 100:1 12 volt geared motors with encoders. I am also using arduino mega with two cytron 10 amp motor controllers for arduino mega and uno. I got my motors working, my encoders working, but not the motors and encoders to work together. I am using the PJRC library to control my encoders as well. For some reason the motors will keep spinning non stop every time I set my speed and distance variables and will keep on spinning even though the encoder has well beyond passed the distance variables.
Here is how my code works. Function move should control the motors and encoders with it’s parameters. The parameters are LeftMotorSpeed, RightMotorSpeed, LeftMotorTicks, and RightMotorTicks. Left and Right motor speed are how fast the motors are moving on a scale of 0 - 255. Right and left motor ticks are the ticks the encoders should make before stopping and returning the function. Any ideas for where I could be going wrong with this? Thank you.
Noah_s_Fire_Fighting_Robot.ino (2.34 KB)