element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum control arduino with android app
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 8 replies
  • Answers 4 answers
  • Subscribers 393 subscribers
  • Views 1643 views
  • Users 0 members are here
Related

control arduino with android app

Former Member
Former Member over 9 years ago

Hey guys.

I'm new here and new to using an Arduino.

Basically all I'm looking to do is to be able to control the pin out puts of my arduino using my android phone using the OTG cable (serial usb).

I've modified a sketch that i found online and i believe it will work, however, i do not know how to code an app to do what i want it to do. I have tried MIT App inventor but it does not seem to allow communication

over a serial link, only bluetooth and i am unsure of how to use android studio or eclipse.

My project is a simple 4 channel relay. If anyone can help or knows of an app which already exist, i would be greatful.

 

Thank you.

 

Here is the sketch that I'm using :

 

int ledpin[6] = {2,4,6,8,10,12};

int ledstate[] = {3,5,7,9,11,13};

String rx="";

byte b = 0;

char c = 'a';

boolean rx_done = false;

 

void setup(){

  pinMode(2,OUTPUT);

  pinMode(4,OUTPUT);

  pinMode(6,OUTPUT);

  pinMode(8,OUTPUT);

  pinMode(10,OUTPUT);

  pinMode(12,OUTPUT);

 

  pinMode(3,INPUT);

  pinMode(5,INPUT);

  pinMode(7,INPUT);

  pinMode(9,INPUT);

  pinMode(11,INPUT);

  pinMode(13,INPUT);

 

  Serial.begin(9600);

}

 

void loop(){

 

  while(Serial.available()){

    char c = (char) Serial.read();

    rx += c;

    delay(2);

  }

 

  if(rx != ""){

    int pin_number = rx.charAt(0)-48;

    //int pin_state = rx.charAt(1)-48;

    if(pin_number > 5){

      //Serial.println("false");

    }

    else{

      int new_state;

      if(digitalRead(ledpin[pin_number]) == HIGH){

        new_state = 0;

        digitalWrite(ledpin[pin_number],new_state);

      } else {

        new_state = 1;

        digitalWrite(ledpin[pin_number],new_state);

      }

     

      String s = rx+new_state;

      Serial.print(s);

    }

   

    rx ="";

  }

 

  delay(1000);

}

  • Sign in to reply
  • Cancel

Top Replies

  • dougw
    dougw over 9 years ago +2 suggested
    If you just want to control relays from android using USB, you could check out EECI. They make the relay card and android app... USB Relay - USB Analog to Digital with Data Logger - RS-232, RS-485 Relay…
  • Former Member
    Former Member over 9 years ago in reply to balearicdynamics +1
    Thank you very much
Parents
  • neilk
    0 neilk over 9 years ago

    Hi ashman  Enrico is correct: the most reliable approach is to use Bluetooth between your Android device and your Arduino.

     

    Bluetooth adapters are readily and cheaply available - HC-06 is very easy to use.

     

    Here is a very simple example, using App Inventor:

     

    https://www.element14.com/community/people/neilk/blog/2014/07/14/mit-app-inventor-creating-android-app-to-control-arduino-via-bluetooth

     

    Hope this helps

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • neilk
    0 neilk over 9 years ago

    Hi ashman  Enrico is correct: the most reliable approach is to use Bluetooth between your Android device and your Arduino.

     

    Bluetooth adapters are readily and cheaply available - HC-06 is very easy to use.

     

    Here is a very simple example, using App Inventor:

     

    https://www.element14.com/community/people/neilk/blog/2014/07/14/mit-app-inventor-creating-android-app-to-control-arduino-via-bluetooth

     

    Hope this helps

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube