Base robot LynxMotion A4WD1 Aluminium



Nu sans carte de contrôle des moteurs : http://www.robotshop.com/eu/robot-kit-aluminium-4wd1.html (possibilité de mettre un STM32Discovery + une carte L298

Avec carte de contrôle des moteurs (Basic) et le pont Sabertooth mais sans batterie : http://www.robotshop.com/eu/productinfo.aspx?pc=RB-Lyn-400&lang=fr-CA

Guides LynxMotion
 * http://www.lynxmotion.com/s-4-electronics-guides.aspx

Bluetooth Controller

 * 1) Add JY-MCU Arduino Bluetooth Wireless Serial Port Module to the pins 10 and 11 of the Arduino board
 * 2) appariez le device BT (le nom par défaut est "RobairBT" ou "linvor") sur votre téléphone Android : la clé par défaut est "1234" : la led rouge du module est fixe (on)
 * 3) utilisez l'application BlueTerm disponible sur l'Android Market Google Play
 * 4) connectez vous au device
 * 5) tapez 'h' pour la liste des commandes de pilotage

// Bluetooth Robot Controller // @author: Didier Donsez, 2013

// see http://arduino.cc/en/Reference/SoftwareSerial
 * 1) include 

SoftwareSerial mySerial(10, 11); // RX, TX

//-- MOTEUR A -- int ENA=5; //Connecté à Arduino pin 5(sortie pwm) int IN1=2; //Connecté à Arduino pin 2 int IN2=3; //Connecté à Arduino pin 3

//-- MOTEUR B -- int ENB=6; //Connecté à Arduino pin 6(Sortie pwm) int IN3=4; //Connecté à Arduino pin 4 int IN4=7; //Connecté à Arduino pin 7

int curDirA=0; // 1=forward, -1=reverse int curSpeedA=0; int curDirB=0; // 1=forward, -1=reverse int curSpeedB=0; int batteryLevel; int batteryNominalLevel=111; // 11.1V int MAX_SPEED=255; // 160 (=255*72/111) for an 7.2V DC motors int curAccelerationStep=32; int defaultSpeed=MAX_SPEED/2;

void setup { configAB; // initialize serial communication: Serial.begin(9600); mySerial.begin(9600); delay(500); mySerial.print("AT+NAMERobairBT"); // Set the name to RobairBT //usage; }

void loop { if (mySerial.available > 0) { int inByte = mySerial.read; Serial.write(inByte); mySerial.write(inByte); switch (inByte) { case ' ': // stop case 'g': // stop stopAB; break; case 't': // forward forwardA; forwardB; speedAB(defaultSpeed); break; case 'v': // reverse reverseA; reverseB; speedAB(defaultSpeed); break; case 'y': // forward right forwardA; forwardB; speedA(defaultSpeed); speedB((defaultSpeed/2)); break; case 'r': // forward left forwardA; forwardB; speedB(defaultSpeed); speedA((defaultSpeed/2)); break; case 'c': // reverse right reverseA; reverseB; speedA(defaultSpeed); speedB((defaultSpeed/2)); break; case 'b': // reverse left reverseA; reverseB; speedB(defaultSpeed); speedA((defaultSpeed/2)); break; case 's': // rotate forwardA; reverseB; speedA(defaultSpeed); speedB(defaultSpeed); break; case 'd': // antirotate reverseA; forwardB; speedA(defaultSpeed); speedB(defaultSpeed); break; case '1': defaultSpeed=MAX_SPEED/9; break; case '2': defaultSpeed=(MAX_SPEED/9)*2; break; case '3': defaultSpeed=(MAX_SPEED/9)*3; break; case '4': defaultSpeed=(MAX_SPEED/9)*4; break; case '5': defaultSpeed=(MAX_SPEED/9)*5; break; case '6': defaultSpeed=(MAX_SPEED/9)*6; break; case '7': defaultSpeed=(MAX_SPEED/9)*7; break; case '8': defaultSpeed=(MAX_SPEED/9)*8; break; case '9': defaultSpeed=MAX_SPEED; break; case 'h': // help case 'u': // help usage; break; default: break; }   inByte=0; } }

void configAB { pinMode(ENA,OUTPUT); pinMode(ENB,OUTPUT); pinMode(IN1,OUTPUT); pinMode(IN2,OUTPUT); pinMode(IN3,OUTPUT); pinMode(IN4,OUTPUT); }

void stopA { digitalWrite(ENA,LOW);// Moteur A - Ne pas tourner (désactivation moteur) }

void stopB { digitalWrite(ENB,LOW);// Moteur B - Ne pas tourner (désactivation moteur) }

void stopAB { stopA; stopB; //delay(??); }

void forwardA { if(curDirA==1) return; stopA; curDirA=1; digitalWrite(IN1,LOW); digitalWrite(IN2,HIGH); }

void reverseA { if(curDirA==-1) return; stopA; curDirA=-1; digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); }

void forwardB { if(curDirB==1) return; stopB; curDirB=1; digitalWrite(IN3,LOW); digitalWrite(IN4,HIGH); }

void reverseB { if(curDirB==-1) return; stopB; curDirB=-1; digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); }

void speedA(int speed) { if(curDirA==0) return; curSpeedA=(speed>=MAX_SPEED)?MAX_SPEED:speed; analogWrite(ENA,curSpeedA); }

void speedB(int speed) { if(curDirB==0) return; curSpeedB=(speed>=MAX_SPEED)?MAX_SPEED:speed; analogWrite(ENB,curSpeedB); }

void speedAB(int speed) { speedA(speed); speedB(speed); }

void rotate { forwardA; reverseB; }

void antirotate { forwardB; reverseA; }

void usage { mySerial.print("Enter keys for drive control \n"); mySerial.print("t = Forward \n"); mySerial.print("v = Backward \n"); mySerial.print("y = Right Forward\n"); mySerial.print("r = Left Forward\n"); mySerial.print("y = Right Backward\n"); mySerial.print("r = Left Backward\n"); mySerial.print("r = Rotate\n"); mySerial.print("d = Antirotate\n"); mySerial.print("1 .. 9 = default speed\n"); mySerial.print("g = Stop \n"); mySerial.print(" = Stop \n"); mySerial.print("(c) Didier Donsez, 2013."); }

Liens

 * http://www.cellbots.com/
 * http://www.instructables.com/id/Android-RC-Car/?ALLSTEPS