Yep got it running well now. Here's the code. I've got the motor running back and forth until i apply a high load near the stall value and above the limit i set and the motor pauses for 7000`ms. Cracking. Thanks Gys, thanks DC. I'll see if i can build this into an RC signal now to switch on and off.
int Bbrake=8;//brake signal for motor B
int Abrake=9;//brake signal for motor A
int motorspdB=11;//PWM speed signal for motor B
int motorspdA=3;//PWM speed signal for motor A
int motorA=12;
int motorB=13;
int sensorPinB = A1; // select the input pin for the current
int sensorValue = 0; // variable to store the value coming from the sensor
//int limit=A0
void setup () {
pinMode (13, OUTPUT);//motor B enable and direction HIGH or LOW
pinMode (12, OUTPUT);//motor A enable and direction HIGH or LOW
pinMode (8, OUTPUT);//Brake motor B
pinMode (9, OUTPUT);//Brake motor A
Serial.begin(9600);//start serial print monitor
}
void loop ()
{
int limit =110; //Value that triggers motor to shutoff once it has reached endpoint
analogWrite (motorspdB,255);
digitalWrite (motorB,HIGH);
digitalWrite (Bbrake,LOW);
delay(1000);
sensorValue = analogRead(sensorPinB);
Serial.println(sensorValue);
delay(1000);
if (sensorValue>limit)
{
digitalWrite (Bbrake,HIGH);
delay(500);
analogWrite (motorspdB,0);
digitalWrite (Bbrake,LOW);
delay(7000);
}
digitalWrite (motorB,LOW);
digitalWrite (Bbrake,LOW);
delay(1000);
}/code]