Arduino Code -> Android Studio?

I have an Arduino Board and a custom PCB connected to it, which is basically a joystick/led/power/potentiometer/pins.

This board allows me to control speed of motor and move up and down.

I have written the Arduino Code that does certain controls to move a motor. It works perfectly.

Problem:

Now, I am moving away from hardware and want to control the motor through an application I am creating on Android Studio. The code for the movement of the motor is already written in Arduino, is there a way to transfer that code that does those certain tasks onto android studio (java), allowing it to behave the same way as it is now but now controlled from my phone?

I understand there may be some changes but do you guys have any tips? Also, I already got a bluetooth connection going by using the HC-05 and it works on app.

The Arduino needs software to run the motors, etc., and that software has to reside in the Arduino.

You need another (totally different) application on the Android device to send messages to the Arduino. (I’m assuming you are not using the joystick on the Android-side?)

On the Arduino-side you’ll need to modify the software to receive the messages and act on them instead of (or in addition to) responding to the joystick.

is there a way to transfer that code that does those certain tasks onto android studio (java), allowing it to behave the same way as it is now but now controlled from my phone?

No. The Arduino doesn’t normally run Java. (But I don’t know if there’s a Java compiler for it.)

And, the Android won’t run the Arduino code, even if it’s re-compiled for the Android. Even if you are using a portable language (such as Java, C/C++), when you get to the microcontroller or hardware level you end-up using lots of machine-specific instructions so it takes a lot of work to port the code to a different platform.

For example, although C and C++ are portable languages, most of the functions in the [u]Arduino Language Library[/u] are not standard ANSI/ISO C++ and they won’t work in a program for the PC or MAC.

And, you’ve probably noticed that there a lots of programs that are available for the PC or the MAC, but not both. Most of these applications are written in “portable” languages, but in practice it’s not so easy to port to a different platform. If it was easy, every application would be available for the PC, MAC, Linux, and maybe even iOS and Android.

I see.

I will not be using the joystick on the hardware (connected to Arduino), since the reason for the app design is to get rid of that and implement it on the app itself.

You need another (totally different) application on the Android device to send messages to the Arduino.

Do you have any suggestions or some references I should look at since this field is sort of new to me, I would really appreciate that. Could you explain further what you mean by this above.

Thank you.