1.0 / August 18, 2018
(4.0/5) (Learn More</a></div>)
Loading...

Description

p00kies HC-05 Bluetooth RC Joystick is a simple app designedtocontrol Arduino Bluetooth projects, using the HC-05BluetoothModule using an analogue Joystick & 4 buttons on yourphone ortablet. The Data produced by the controls is sent out as astringof integers. Use the following sketch which shows how thedata isrecieved and sorted. The ArduinoSketch//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////#includeSoftwareSerial mySerial(12, 11); // connect D12 to the TXon theHC-05 & D11 to RX on HC-05 const byte numChars = 16;charreceivedChars[numChars]; char recvChar; char endMarker ='>';boolean newData = false; int joyX = 50; //Joystick X Axisint joyY =50; //Joystick X Axis int btnA = 0; //Button A int btnX= 0;//Button X int btnB = 0; //Button B int btnY = 0; //Button Yvoidsetup() { //HC-05 Serial Connection mySerial.begin(9600);//USBSerial Connection Serial.begin(9600); Serial.println(""); }voidloop() { recvData(); showData(); //Worth removing when doingyourown project //yourFunction(); //Place holder for your function//SeeBelow } //Recieve incoming Data & store as a StringvoidrecvData() { static byte nData = 0; char badByte = ':';chargoodByte = ','; char endMarker = '>'; char rc;while(mySerial.available() > 0 && newData == false) { rc=mySerial.read(); if (rc != endMarker) { if(rc == badByte) rc=goodByte; receivedChars[nData] = rc; nData++; if (nData>=numChars) { nData = numChars - 1; } } else {receivedChars[nData] ='\0'; // terminate the string nData = 0;parseData(); } } } //Sortthe Data & Store in Variables for usevoid parseData() { //split the data char * strtokIndx; // this isused by strtok() as anindex strtokIndx = strtok(receivedChars,",");// Get 1st Chunk fromData string joyX = atoi(strtokIndx); //Retrieve 1st value &convert to an integer strtokIndx =strtok(NULL, ","); // Find NextChunk joyY = atoi(strtokIndx); //Retrieve 2nd value & convertto an integer strtokIndx =strtok(NULL, ","); // Find Next ChunkbtnA = atoi(strtokIndx); //Retrieve 3rd value & convert to aninteger strtokIndx =strtok(NULL, ","); // Find Next Chunk btnX =atoi(strtokIndx); //Retrieve 4th value & convert to an integerstrtokIndx =strtok(NULL,","); // Find Next Chunk btnB =atoi(strtokIndx); //Retrieve 5th value & convert to an integerstrtokIndx =strtok(NULL, ","); // Find Next Chunk btnY =atoi(strtokIndx);//Retrieve 6th value convert this part to aninteger newData = true;} //Show the incoming Data over localSerial(Debug)// voidshowData() { //Check you have newData to workwith if (newData ==true) { //Here I'm stupidly reconcatinating theString for yourviewing pleasure :D String output = String(joyX) +"," +String(joyY) + "," + String(btnA) + "," + String(btnX) + ","+String(btnB) + "," + String(btnY); //Shouting it out over thelocalserial assuming your testing the Arduino over usb (RX0,TX1)Serial.println(output); //And now Clearing the newData flagtostart the process over newData = false; } } //Here's theplaceholder function with the nessacaries included voidyourFunction(){//Check you have newData to work with if (newData ==true) { //Doyour thang here! //But remember to finish by clearingnewData flagnewData = false; }}/////////////////////////////////////////////////////////////////////////////////////////////////Enjoy!**Notes ***This App WILL Eat Your Battery

App Information p00kies HC-05 Bluetooth RC Joystick

  • App Name
    p00kies HC-05 Bluetooth RC Joystick
  • Package Name
    com.p00ky.p00kiesimplehc_05serialbluetoothjoystick
  • Updated
    August 18, 2018
  • File Size
    1.4M
  • Requires Android
    Android 4.2 and up
  • Version
    1.0
  • Developer
    p00ky
  • Installs
    5+
  • Price
    Free
  • Category
    Education
  • Developer
    Maesyfed, Penybont, Llanadrindod Wells, Powys, LD1 5UA
  • Google Play Link

p00ky Show More...

p00kies HC-05 Bluetooth RC Joystick 1.0 APK
p00ky
p00kies HC-05 Bluetooth RC Joystick is a simple app designedtocontrol Arduino Bluetooth projects, using the HC-05BluetoothModule using an analogue Joystick & 4 buttons on yourphone ortablet. The Data produced by the controls is sent out as astringof integers. Use the following sketch which shows how thedata isrecieved and sorted. The ArduinoSketch//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////#includeSoftwareSerial mySerial(12, 11); // connect D12 to the TXon theHC-05 & D11 to RX on HC-05 const byte numChars = 16;charreceivedChars[numChars]; char recvChar; char endMarker ='>';boolean newData = false; int joyX = 50; //Joystick X Axisint joyY =50; //Joystick X Axis int btnA = 0; //Button A int btnX= 0;//Button X int btnB = 0; //Button B int btnY = 0; //Button Yvoidsetup() { //HC-05 Serial Connection mySerial.begin(9600);//USBSerial Connection Serial.begin(9600); Serial.println(""); }voidloop() { recvData(); showData(); //Worth removing when doingyourown project //yourFunction(); //Place holder for your function//SeeBelow } //Recieve incoming Data & store as a StringvoidrecvData() { static byte nData = 0; char badByte = ':';chargoodByte = ','; char endMarker = '>'; char rc;while(mySerial.available() > 0 && newData == false) { rc=mySerial.read(); if (rc != endMarker) { if(rc == badByte) rc=goodByte; receivedChars[nData] = rc; nData++; if (nData>=numChars) { nData = numChars - 1; } } else {receivedChars[nData] ='\0'; // terminate the string nData = 0;parseData(); } } } //Sortthe Data & Store in Variables for usevoid parseData() { //split the data char * strtokIndx; // this isused by strtok() as anindex strtokIndx = strtok(receivedChars,",");// Get 1st Chunk fromData string joyX = atoi(strtokIndx); //Retrieve 1st value &convert to an integer strtokIndx =strtok(NULL, ","); // Find NextChunk joyY = atoi(strtokIndx); //Retrieve 2nd value & convertto an integer strtokIndx =strtok(NULL, ","); // Find Next ChunkbtnA = atoi(strtokIndx); //Retrieve 3rd value & convert to aninteger strtokIndx =strtok(NULL, ","); // Find Next Chunk btnX =atoi(strtokIndx); //Retrieve 4th value & convert to an integerstrtokIndx =strtok(NULL,","); // Find Next Chunk btnB =atoi(strtokIndx); //Retrieve 5th value & convert to an integerstrtokIndx =strtok(NULL, ","); // Find Next Chunk btnY =atoi(strtokIndx);//Retrieve 6th value convert this part to aninteger newData = true;} //Show the incoming Data over localSerial(Debug)// voidshowData() { //Check you have newData to workwith if (newData ==true) { //Here I'm stupidly reconcatinating theString for yourviewing pleasure :D String output = String(joyX) +"," +String(joyY) + "," + String(btnA) + "," + String(btnX) + ","+String(btnB) + "," + String(btnY); //Shouting it out over thelocalserial assuming your testing the Arduino over usb (RX0,TX1)Serial.println(output); //And now Clearing the newData flagtostart the process over newData = false; } } //Here's theplaceholder function with the nessacaries included voidyourFunction(){//Check you have newData to work with if (newData ==true) { //Doyour thang here! //But remember to finish by clearingnewData flagnewData = false; }}/////////////////////////////////////////////////////////////////////////////////////////////////Enjoy!**Notes ***This App WILL Eat Your Battery
Loading...