Ref: https://robotics.stackexchange.com/q/8526/11146

I want to build a simple android controlled robot

I will connect android phone<usb>arduino<wire>motor controller<wire>dc motor

I wonder why I have to write two programs (android java & arduino c++)?

How can I directly control the DC motor from android java program without writing arduino code?

  • You could possibly utilize something like Firmata with minimal modifications, or potentially use a USB I/O chip instead of an Arduino, but these are likely to be inferrior to a custom solution - if you aren't willing to touch something as accessible as Arduino code, it's questionable if the project is practical for you. Commented Nov 22, 2015 at 17:05
  • It's not clear what you'd like to do, but for some applications one of the simpler ways to do this would be to add a wifi module to the Arduino and use a simple web interface to get the commands from the Android.
    – dlu
    Commented Nov 22, 2015 at 17:22

1 Answer 1


The short answer is "you can't." For the Arduino to do anything useful it needs to have instructions telling it what to do. In your example the Arduino's job is to do something that the Android can't – turn on and off the DC motor. You could even use a wifi or Bluetooth connection from the Android to the Arduino to make it possible to avoid the hassle of the USB cable.

Your project requires a number of small hunks of code on the Arduino to:

  • Listen for commands from the Android.
  • Validate the commands received.
  • Turn on or off the motor.

Roughly speaking your loop() function might look something like this:

void loop() {
  // look for a command
  // validate the command
  if (valid && turn_motor_on) {
  } else {

Fortunately the Arduino code can be very simple and there is a lot of example code to help you get started.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.