Documentation

Joystick app works with Arduino


Analog Controller for Arduino using Bluetooth HC-05

Analog Controller for Arduino is a handy controller to control your robots using Gamepad. The app transmits analog data encoded into a special format, this data is then decoded by Arduino using the given code. On the Serial monitor of Arduino you can see three values; angle, the strength of analog stick and button pressed.

...

Android App Logic

  • There are 5 buttons on the screen namely black, red, green, yellow, blue.

  • Black button is joystick, same like real Joystick controller - Joystick provide 2 values

    • Angle [ 0 - 359 ]
    • Strength [ 0 - 100 ]
  • Rest of the buttons (red, green, yellow, blue) are normal buttons, by default there values are set to 0. You can changes the values by going to Menu > Setting.
  • Joystick, red, green, yellow, blue button values will be visible on the left and right of < Sending Data > in real time.
  • Combination of these all buttons (data) is sent through bluetooth
    • By default seven digit number is set 0000000
    • First three digit represent Angle
    • Second three digit represent Strength
    • Last one digit represent the values of button blue, green, red, yellow
  • Example: the seven digit number is 2700891, So
    • First three digit represent Angle i.e : 270
    • Second three digit represent Strength i.e : 089
    • Last one digit represent the values of button blue, green, red, yellow i.e : 1

2700891 will be sent to arduino through bluetooth

...

Joystick Advance

  • void setup() {
  • Serial.begin(9600);
  • }
  • void loop() {
  • if(Serial.available()>0)
  • {
  • String value = Serial.readStringUntil('#');
  • if(value.length()==7)
  • {
  • String angle = value.substring(0, 3);
  • String strength = value.substring(3, 6);
  • String button = value.substring(6, 8);
  • Serial.print("angle: ");Serial.print(angle);Serial.print('\t');
  • Serial.print("strength: ");Serial.print(strength);Serial.print('\t');
  • Serial.print("button: ");Serial.print(button);Serial.println("");
  • Serial.flush();
  • value="";
  • }
  • }
  • }
...

Joystick and Accelerometer

  • void setup() {
  • Serial.begin(9600);
  • }
  • void loop() {
  • if(Serial.available()>0)
  • {
  • String value = Serial.readStringUntil('#');
  • if(value.length()==2)
  • {
  • String joystick = value.substring(0, 1);
  • String button = value.substring(1, 2);
  • String button = value.substring(6, 8);
  • Serial.print("Direction: ");Serial.print(joystick);Serial.print('\t');
  • Serial.print("Button: ");Serial.print(button);Serial.println("");
  • Serial.flush();
  • value="";
  • }
  • }
  • }

Google Playstore