Программирование Bluetooth BTM222
Материал из BrSTU Robotics Wiki
Пример прошивки Arduino:
{ /* * Setup bluetooth board. Need for the first bluetooth board boot. * Send "L5" control sequence on 19200bps baud rate. * 'L5' - specify the baud rate of COM port to 115200bps */ void btSetup() { Serial.begin(19200); Serial.println("L5"); for (int i = 0; i < 5; i++) { Serial.flush(); delay(5); } } char readSerial() { char val = Serial.read(); return val; } // Initialization method void setup() { btSetup(); // setup serial port Serial.begin(19200); } char cmd; // Main loop void loop() { cmd = 0; if (Serial.available()) { cmd = readSerial(); switch (cmd) { case 'f': // Do something, when get 'f' break; case 's': // Do something, when get 's' break; default : break; // Do something, when get something else } } delay(10); }