Browse Source

Adicionar bluetooth

master 0.1.0
Duarte Milhinhos 2 years ago
parent
commit
fea5453eec
  1. 41
      motor.ino

41
motor.ino

@ -1,20 +1,37 @@
int pushButton = 2;
int recv = 0;
// the transistor which controls the motor will be attached to digital pin 9
int motorControl = 3;
// 0 FORWARD
// 1 BACKWARD
// 2 LEFT
// 3 RIGHT
// the setup routine runs once when you press reset:
void setup() {
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
// make the transistor's pin an output:
pinMode(motorControl, OUTPUT);
Serial.begin(115200); //initial the Serial
}
// the loop routine runs over and over again forever:
void loop() {
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");
}
analogWrite(motorControl, 0);
}
}
Loading…
Cancel
Save