2018-08-18 12:05 AM
I using bluetooth to control the drone by sending single character. But when i press the button on my phone, they is nothing happen on the drone. So, i think that my arduino coding is not complete yet.....
Below is my coding:
#define M1_PIN PA8
#define M2_PIN PA7
#define M3_PIN PA6
#define M4_PIN PA1
#define tx PB11
#define rx PB10
char blue = 0;
String readb;
void setup() {
pinMode(M1_PIN, OUTPUT);
pinMode(M2_PIN, OUTPUT);
pinMode(M3_PIN, OUTPUT);
pinMode(M4_PIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
if(Serial.available()> 0){
blue = Serial.read();
readb += blue;
}
if(readb == "O"){
analogWrite(M1_PIN, 65535);
analogWrite(M2_PIN, 65535);
analogWrite(M3_PIN, 65535);
analogWrite(M4_PIN, 65535);
readb = "";
}
else if (readb == "S"){
analogWrite(M1_PIN, 0);
analogWrite(M2_PIN, 0);
analogWrite(M3_PIN, 0);
analogWrite(M4_PIN, 0);
delay(5000);
readb = "";
}
}
2018-08-18 06:25 PM
is this MBED ?
maybe you should use the MBED forum...
I rarely see any MBED issues questioned here, not sure if anyone is using it on this site.
2018-08-18 09:02 PM
ARDUINO != MBED