initial import

This commit is contained in:
estevez
2017-12-24 17:10:53 +02:00
parent 703c29b67e
commit b181cacb8f
37 changed files with 779 additions and 0 deletions

View File

@ -0,0 +1,51 @@
#include <SparkFun_TB6612.h>
#include <SoftwareSerial.h>
#define AIN1 4
#define BIN1 8
#define AIN2 5
#define BIN2 9
#define PWMA 7
#define PWMB 10
#define STBY 6
const int offsetA = 1;
const int offsetB = 1;
SoftwareSerial BTSerial(3, 2); // RX | TX
String reader;
int d = 0;
Motor motor1 = Motor(AIN1, AIN2, PWMA, offsetA, STBY);
Motor motor2 = Motor(BIN1, BIN2, PWMB, offsetB, STBY);
void setup()
{
Serial.begin(9600);
Serial.println("Ready:");
BTSerial.begin(9600); // HC-05 default speed in AT command more
}
void loop()
{
reader="";
while (BTSerial.available()) {
delay(3);
if (BTSerial.available()>0) {
char c = BTSerial.read();
reader += c;
}
}
if (reader.length() > 0) {
Serial.println("Receved: "+reader+"");
d = reader.toInt();
}
if (d == 11) {
motor1.drive(255);
} else if (d == 12) {
motor1.drive(-255);
}
}