It works!
This commit is contained in:
		| @@ -5,17 +5,17 @@ | ||||
| #define AIN1 4 | ||||
| #define BIN1 8 | ||||
| #define AIN2 5 | ||||
| #define BIN2 9 | ||||
| #define PWMA 7 | ||||
| #define BIN2 7 | ||||
| #define PWMA 11 | ||||
| #define PWMB 10 | ||||
| #define STBY 6 | ||||
|  | ||||
| const int offsetA = 1; | ||||
| const int offsetB = 1; | ||||
| const int offsetB = -1; | ||||
|  | ||||
| SoftwareSerial BTSerial(3, 2); // RX | TX | ||||
| String reader; | ||||
| int d = 0; | ||||
| int d = 600; | ||||
| Motor motor1 = Motor(AIN1, AIN2, PWMA, offsetA, STBY); | ||||
| Motor motor2 = Motor(BIN1, BIN2, PWMB, offsetB, STBY); | ||||
|  | ||||
| @@ -24,6 +24,7 @@ void setup() | ||||
|   Serial.begin(9600); | ||||
|   Serial.println("Ready:"); | ||||
|   BTSerial.begin(9600);  // HC-05 default speed in AT command more | ||||
|   brake(motor1, motor2); | ||||
| } | ||||
|  | ||||
| void loop() | ||||
| @@ -41,11 +42,13 @@ void loop() | ||||
|     Serial.println("Receved: "+reader+""); | ||||
|     d = reader.toInt();     | ||||
|   } | ||||
|   | ||||
|   if (d == 11) { | ||||
|     motor1.drive(255); | ||||
|   } else if (d == 12) { | ||||
|     motor1.drive(-255); | ||||
|  | ||||
|   if (d <= 500) { //0 - full back, 255 - stop, 500 - full forward | ||||
|     int v1 = d - 255; | ||||
|     motor1.drive(v1);   | ||||
|   } else if (d >= 1000) { // 1000 - full back, 1255 - stop, 1500 - full forward | ||||
|     int v2 = d - 1255;  | ||||
|     motor2.drive(v2);   | ||||
|   } | ||||
|    | ||||
|   | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user