I'm in need to control this driver. i don't want to use the shield which is dual because i'm using the ethernet shield. I can't find any on the internet how to program this thing.
Here's the pin i used.
Arduino VNH5019
digital 3-----------------PWM
digital 7-----------------INA
digital 8-----------------INB
Here's the code i wrote.
const int INA = 7;
const int INB = 8;
const int PWM_PIN = 3;
void setup(){
pinMode(INA, OUTPUT);
pinMode(INB, OUTPUT);
pinMode(PWM_PIN, OUTPUT);
Serial.begin();
}
void loop(){
if(Serial.available() >=2){
byte cmd1 = 0;
byte cmd2 = 0;
cmd1 = (byte)Serial.read();
cmd2 = (byte)Serial.read();
if(cmd1=='m' && cmd2=='f'){ // if serial read "mf" forward motor
digitalWrite(INA, HIGH);
digitalWrite(INB, LOW);
}
else if(cmd1=='r' && cmd2=='m') //if serial read "rm" reverse motor
digitalWrite(INB, HIGH);
digitalWrite(INA, LOW);
if(cmd1=='i' && cmd2=='s'){ // if serial read "is" then increment speed.
How do i speed up motor here?
}
else if(cmd1=='d' && cmd2=='s'){ // if serial read "ds" then decrease speed.
How do i decrease the speed here?
}
}
}
How do i control the speed of it?
Thanks.