Advertisement
DrAungWinHtut

Bluetooth.ino

Jun 17th, 2022
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<SoftwareSerial.h>
  2.  
  3. SoftwareSerial  bluetooth(12,11);
  4. void setup() {
  5.   Serial.begin(9600);
  6.   bluetooth.begin(9600);
  7. }
  8.  
  9. void loop() {
  10.   if(Serial.available())
  11.   {
  12.     int iData = Serial.read();
  13.     //Serial.write(iData);
  14.     Serial.println(iData,DEC);
  15.     if(iData==97)
  16.     {
  17.       Serial.println("Hello World");
  18.     }
  19.   }
  20.  
  21.   if(bluetooth.available())
  22.   {
  23.     int iData = bluetooth.read();
  24.     //Serial.write(iData);
  25.     Serial.write(iData);
  26.     if(iData=='F')
  27.     {
  28.       Serial.println("Forward");
  29.     }
  30.     if(iData=='B')
  31.     {
  32.       Serial.println("Backward");
  33.     }
  34.     if(iData=='R')
  35.     {
  36.       Serial.println("Right");
  37.     }
  38.     if(iData=='L')
  39.     {
  40.       Serial.println("Left");
  41.     }
  42.   }
  43.  
  44.  
  45.   //delay(100);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement