

#Two dc motors arduino reverse driver
The Encoder Counting section of the code I have taken from a project that was very similar and had a similar goal with how they wanted their dc motor to run and so I am not sure that it is correct for what I require.Ī motor driver: Pololu - Dual VNH2SP30 Motor Driver Carrier MD03AĭC motor with encoder: Pololu - 4.4:1 Metal Gearmotor 25D圆0L mm HP 6V with 48 CPR Encoder (No End Cap)

I am sure this is what is happening as I have kept the number of turns constant but changed the speed and delay values and they seem to match with what is happening.Ĭan anyone help me with my code and see where I am going wrong? When I run this code however, it appears to just be running at the speed I have set for the duration of the delay. I was curious to see if tit was actually turning the set amount so I changed the code to run it at 50 speed (roughly 20% of max speed) for just 5 revolutions.

From what I have learned so far and found online from other similar projects I have created a code (that will eventually control 2 DC motors but just 1 for just now) that should turn the motor at full speed (255) for 40 revolutions then pause for a few seconds before turning in the opposite direction at full speed for 40 turns. I am extremely new to Arduino and have very little experience in any form of coding. My part of the project is coding the DC motors to run a set number of turns at a set speed and then reverse direction. I am currently doing a project in which I am using a Twisted String Actuator for an assistive leg brace.
