Go Down

Topic: Motor Shield v1 (Read 1 time) previous topic - next topic

Ardui_Noob

Quick question...  can you SIMULTANEOUSLY control two motors with this shield?  For example, I want to, in the same if statement, set motor A to speed 256 and motor B to speed 80?  Right now I haven't had any success at this.  Any help or insight?

Ardui_Noob

Sorry, I know my first post was very vague.  I was forced to use my phone for internet since my home service was down.  I am back up again so here is the code that is giving me troubles:

Code: [Select]

int oldValue = 0;


void setup() {

  pinMode(9 , OUTPUT);
 
  pinMode(10 , OUTPUT);
 
  Serial.begin(9600);

}

void loop() {

  int potValue = analogRead(A1);
 
 
  if ( potValue != oldValue ) {

    dualMotorSteering ( potValue );
   
    oldValue = potValue ;

  }

   
  // Serial.println (potValue, DEC); 
 
}
 
 
 
 
 
 
void dualMotorSteering (int sensorValue) {
 

int motorVal ;
int speedVal ;



Serial.print (sensorValue);
 
if (sensorValue > 0 && sensorValue < 131) {
  motorVal = 1 ;
  speedVal = 0 ;
}
 
if (sensorValue > 130 && sensorValue < 151) {
  motorVal = 1 ;
  speedVal = 85 ;
}

if (sensorValue > 150 && sensorValue < 166) {
  motorVal = 1 ;
  speedVal= 170 ;
}


if (sensorValue > 205 && sensorValue < 251) {
  motorVal = 2 ;
  speedVal = 170 ;
}

if (sensorValue > 250 && sensorValue < 361) {
  motorVal = 2 ;
  speedVal= 85 ;
}

if (sensorValue > 360) {
  motorVal = 2 ;
  speedVal = 0 ;
}
   
   
   
   switch ( motorVal ) {
   
   case 1 :
       analogWrite ( 9 , speedVal );
       analogWrite ( 10 , 256 );
      break;
     
      case 2 :
      analogWrite ( 10 , speedVal );
      analogWrite ( 9 , 256 );
      break;

}



Serial.println ("  ");
Serial.println ("out");
return;

}

Binette228

Hi,

What is the motor shield V.1 ? Can you give us a link to the motor driver manual?
Are you having trouble with the code and/or you don't know if it can drive two motors?

Ardui_Noob

Incase anyone else was wondering... Yes, the v1 motor shield will run 2 motors at the same time.  I ended up modifying someone elses code to get it running.  I think there were 2 issues with the set up I was using.  1) Somewhere I had read that the motor speed can be between 0 and 256.  If you use 256 the motor doesn't run. 2) Some of the sample code out there uses direction and speed pins that do not match the v1 board.  After looking at the pinout listed with the schematic listed here: http://mcukits.com/2009/03/12/assembling-the-freeduino-arduino-motor-shield/  I was able to identify the correct pins for the board.  If anyone else out there is having similar issues, hope this helps!

Go Up