Pages: [1]   Go Down
Author Topic: Motor Shield v1  (Read 1173 times)
0 Members and 1 Guest are viewing this topic.
Ohio
Offline Offline
Newbie
*
Karma: 2
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Ohio
Offline Offline
Newbie
*
Karma: 2
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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;

}
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Ohio
Offline Offline
Newbie
*
Karma: 2
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Pages: [1]   Go Up
Jump to: