Guest User

Untitled

a guest
May 17th, 2021
93
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // FCF5C408662A,ESP32,2C110
  2.  
  3. #include <SoftwareSerial.h>  
  4.  
  5. int bluetoothTx = 2;  // TX-O pin of bluetooth mate, Arduino D2
  6. int bluetoothRx = 3;  // RX-I pin of bluetooth mate, Arduino D3
  7.  
  8. SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
  9.  
  10. void setup()
  11. {
  12.   Serial.begin(9600);  // Begin the serial monitor at 9600bps
  13.  
  14.   bluetooth.begin(115200);  // The Bluetooth Mate defaults to 115200bps
  15.   bluetooth.print("$");  // Print three times individually
  16.   bluetooth.print("$");
  17.   bluetooth.print("$");  // Enter command mode
  18.   delay(100);  // Short delay, wait for the Mate to send back CMD
  19.   bluetooth.println("U,9600,N");  // Temporarily Change the baudrate to 9600, no parity
  20.   // 115200 can be too fast at times for NewSoftSerial to relay the data reliably
  21.   bluetooth.begin(9600);  // Start bluetooth serial at 9600
  22. }
  23.  
  24. void loop()
  25. {
  26.   if(bluetooth.available())  // If the bluetooth sent any characters
  27.   {
  28.     // Send any characters the bluetooth prints to the serial monitor
  29.     Serial.print((char)bluetooth.read());  
  30.   }
  31.   if(Serial.available())  // If stuff was typed in the serial monitor
  32.   {
  33.     // Send any characters the Serial monitor prints to the bluetooth
  34.     bluetooth.print((char)Serial.read());
  35.   }
  36.   // and loop forever and ever!
  37. }
  38.  
RAW Paste Data