Adicionar bluetooth

This commit is contained in:
Duarte Milhinhos 2019-04-13 15:21:59 +01:00
parent 3abd9be011
commit fea5453eec
1 changed files with 29 additions and 12 deletions

View File

@ -1,20 +1,37 @@
int pushButton = 2; int recv = 0;
// the transistor which controls the motor will be attached to digital pin 9 // 0 FORWARD
int motorControl = 3; // 1 BACKWARD
// 2 LEFT
// 3 RIGHT
// the setup routine runs once when you press reset:
void setup() { void setup() {
// make the pushbutton's pin an input: Serial.begin(115200); //initial the Serial
pinMode(pushButton, INPUT);
// make the transistor's pin an output:
pinMode(motorControl, OUTPUT);
} }
// the loop routine runs over and over again forever:
void loop() { void loop() {
analogWrite(motorControl, 0); if (Serial.available()) {
switch (Serial.read())
{
case 0:
Serial.println("MOVING FORWARD");
break;
case 1:
Serial.println("MOVING BACKWARD");
break;
case 2:
Serial.println("MOVING LEFT");
break;
case 3:
Serial.println("MOVING RIGHT");
break;
default:
Serial.println("INVALID INSTRUCTION");
}
}
} }