create android app to control arduino car
with bluetooth
I'll just paste the Steps here, in case the link expires someday.
1. At the top of your source code, include these libs.
2. #include "SoftwareSerial.h"
#include "Bluetooth.h"
3. To start using it, at the top of your source declare a public variable to access it:
Bluetooth *blue = new Bluetooth(2, 3);
With Bluetooth(RX_Pin, TX_Pin)
The default pin is 1234, name is “PNGFramework” and baudrate is 9600
4. Now, on your Setup(), add the follow line:
5. void setup(){
6. Serial.begin(9600);
7. blue->setupBluetooth();
}
8. Send a message when we receive some data from Serial.
9. void loop(){
10. String msg = blue->Read();
11. if(msg.length() > 1){
12. Serial.print("Received: ");
13. Serial.println(msg);
14. }
15. if(Serial.available()){
16. blue->Send("Example message#");
17. }
}
In Android
1. First, create a bluetooth object, use the following code, make sure to use the same
RobotName that you used in the Arduino project. (default is “PNGFramework”).
BluetoothArduino mBlue = BluetoothArduino.getInstance("PNGFramework");
2. To connect with the Arduino, add the command bellow:
mBlue.Connect();
3. Now, to read a message, run the command:
String msg = mBlue.getLastMessage();