I have a VEX Motor Module(3-wires) that our teacher had from a Vex Kit. I have the Arduino to slowly rise the PWM from 0-255 and then lower it down. What I have found is that the motor starts moving when the PWM is at around 40. I know that around 120, the motor starts slowing down and at 170, it stops completely. Once it is at 200, the motor starts again but in the opposite direction, slow at first but gets faster around 250. At 255, the motor stops completely and at 254, it starts again. Again the motor doesnt move when the PWM is between 200 and 170 and after that, it turns again in the original direction and stops at 40.
I dont know why this is happening but the duty cycle frequency was wrong, then why does it stop completely at 255? When I hook up the pwm and ground on the arduino to a regular dc motor that you would find in an electronics kit, the motor works just like how pwm should.
Here is the code I ran:
Code:
boolean increasing;
int x;
void setup() {
x=0;
Serial.begin(9600);
increasing = true;
}
void loop()
{
Serial.println(x);
analogWrite(9,x);
if (increasing)
{
x++;
}
else
{
x--;
}
if(x==255)
{
increasing = false;
}
if (x==0)
{
increasing = true;
}
delay(500);
}