Issue
want to create android app to upload .hex file to arduino uno via USB. Sketch IDE creates .hex file after compiling program .And able to upload to arduino uno via USB. So can any body tell me that how make android app to upload .hex file to arduno uno . There is app called "Arduino Commander" on google play store who can able upload using USB. And also I want to know android source code for that
Solution
i do not know exactly what you mean this is why this is divided in two parts:
either you want to use the arduino's virtual COM port to write a binary file to EEPROM or flash using RS-232 protocol.
or you want to flash a .hex file (write a self written and compiled program to the arduino) via its bootloader over USB (DFU programming). i think you want to do the first one
normally arduino uno's USB implements the USB CDC ACM class ( https://en.wikipedia.org/wiki/USB_communications_device_class ) and is a Virtual COM port. So you can communicate with RS-232 protocol/commands over USB from android to arduino.
on the android side there is a USB host driver (https://github.com/mik3y/usb-serial-for-android) that enables your android to enumerate Virtual COM ports (USB CDC ACM devices) like the arduino.
in this situation the android is USB host the arduino is USB device. In USB protocol there can only one device be in host mode all other devices have to be in device mode then
so on your android you can include the usb-serial-for-andoid driver in your project and then use RS-232 commands to communicate with the arduinos virtual COM, an example is in https://github.com/mik3y/usb-serial-for-android .
on your arduino you have to implement a software that understands the commands it receives over the virtual com port, see https://www.arduino.cc/en/Tutorial/SoftwareSerialExample for RS-232 on arduino
by this you can implement a similar functionality like Arduino Commander https://www.arduino.cc/en/Main/USBSerial
you can also ask arduino questions at http://arduino.stackexchange.com
(http://www.v-lad.org/projects/gnu.io.android/)
the programming of the arduino (flashing a .hex) over USB port works because the Arduino chip has a preinstalled bootloader (http://wiki.osdev.org/Bootloader). this is called DFU (Device Firmware Update). DFU is a special USB protocol. you can follow this tutorial https://www.arduino.cc/en/Hacking/DFUProgramming8U2 note that when you do this you overwrite /delete any firmware that is on the arduino (except the bootloader and some other low-level tasks) and replace it with your newly developed
there is no android app for this and arduino commander is not able to do this, this is why i do not think you want to do this (DFU using android as host)
Answered By - ralf htp