Go Down

Topic: Android Bluetooth to Arduino (Read 101594 times) previous topic - next topic

Christian_R

#15
Nov 26, 2014, 05:28 pm Last Edit: Nov 26, 2014, 05:30 pm by Christian_R
Don't forget to add those two lines in your manifest.

    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>

Otherwise the app will crash.

Please could you explain what does it means? Where is located this manifest file ?
Christian

popfansin

Hello,

I tried your codes but I can't seem to turn ON/OFF the led using your writeData(). I think arduino does not receive the value from android. Please can you help me figure it out. By the way. Here's my sketch:

int led = 13;
char inbyte = '0';
void setup() {
  Serial.begin(9600);
 pinMode(led, OUTPUT);
 digitalWrite(led, LOW);
}

void loop() {
 
if (Serial.available() > 0)
 {
   inbyte = Serial.read();
   if (inbyte == '0')
   {
     //LED off
     digitalWrite(led, LOW);
   }
   if (inbyte == '1')
   {
     //LED on
     digitalWrite(led, HIGH);
   }
 }
}

boinerz

#17
Feb 03, 2015, 12:28 am Last Edit: Feb 03, 2015, 12:54 am by boinerz
Hi,,

I've been watching developments for two years toward implementation of a smartphone dialer. Now via Bluetooth and the Anaren AIR interface shown last month in Nuts & Volts, I'm interested in finding someone who can assemble a Java application for the LG840G, and other LG smartphones.

Initially, I may try to develop a VB application to mimic/demonstrate LG840G functionality via the Bluetooth interface to Arduino. This would simplify development of the demonstration of various ideas. Java development could happen in phase two, possibly using an emulator.

I'd like to develop the Arduino to VB connection using simple VB code. I'll bet VB will simply treat the Bluetooth connection as a COMM port, so a primitive VB to Arduino application that implements the connection via USB, will also support the Bluetooth connection. I'm guessing, all I need do is identify the Bluetooth COMM port and process buffer I/O sames as for USB which worked fine.

Once this is verified, I can develop VB functionality of the Java application I want to develop for the LG840G which I have prepaid for just $6/month until 2017. I could easily afford to get a second phone dedicated to development and testing at this price, but if a suitable emulator exists, I'll use it.

LG Java development SDK and requirements seem a little daunting, however there is open source available which can be hacked, adding Bluetooth support, and needed features...

Is anyone interested in this project?

LINK to LG840G SDK...

:)


kevin2300

hello Jon17...

i am working on an android arduino project where i want to send data to arduino and in return i want the arduino to send the data back to android..i am planning to send the data via a button in android such that if i press a button the android should instruct the arduino to display the data..the data is the temperature sensor which is connected to the arduino mega 2560 board..

i downloaded your app from the forum and i ran it in eclipse by connecting it to my android mobile but when the app runs it shows a message "Unfortunately Light Remote has stopped working"...even before turning on the bluetooth ...

i dnt know what is wrong with it...

i need your help i am using the latest version of eclipse with a target sdk of 21...please i need your help in figuring out what is wrong ..

BamBam

I copied and pasted this; http://pastebin.com/a7wPqA3d into sketch and then clicked upload. It said there is an error: stray '@' in program.

All I want to do is enable my Arduino Duemilanove to except bluetooth to control a servo motor using the Android App on Google Play.

I have no knowledge of all this Arduino stuff so I am hoping that someone here can guide a dummy step by step.

I promise I will go away then. 

BamBam

Trust I am trying but what am I doing wrong?

error:'class HardwareSerial' has no member named 'parseint'

Also in box below (in sketh)...

in function 'void loop () ':
error: 'class HardwareSerial' has no member named 'parseint'


#include <Servo.h>
 
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created
 
int pos = 0;    // variable to store the servo position
int motor = 0;
 
void setup()
{   
  Serial.begin(9600);  // initialize serial: 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
 
  Serial.print("Arduino control Servo Motor Connected OK");
  Serial.print('\n');
}
 
void loop()

  // if there's any serial available, read it:
  while (Serial.available() > 0) {
     
    // look for the next valid integer in the incoming serial stream:
    motor = Serial.parseInt();
   
    // do it again:
    pos = Serial.parseInt();
   
    // look for the newline. That's the end of your  sentence:
    if (Serial.read() == '\n') {
               
       myservo.write(pos);              // tell servo to go to position in variable 'pos'
       delay(15);                       // waits 15ms for the servo to reach the position
     
      // print the three numbers in one string as hexadecimal:
      Serial.print("Data Response : ");
      Serial.print(motor, HEX);
      Serial.print(pos, HEX);
       
    }
  }
}
 
  //for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  //{                                  // in steps of 1 degree
  //  myservo.write(pos);              // tell servo to go to position in variable 'pos'
  //  delay(15);                       // waits 15ms for the servo to reach the position
  //}
  //for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  //{                               
  //  myservo.write(pos);              // tell servo to go to position in variable 'pos'
  //  delay(15);                       // waits 15ms for the servo to reach the position
  //}
 
 
  //val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
  //val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
  //myservo.write(val);                  // sets the servo position according to the scaled value
  //delay(15);

BamBam

The Sketch then highlights this...

motor = Serial.parseInt();


CarlosEC

Hi !

I am sending a letter from an Android phone to my Arduino, using Bluetooth.
When I send the letter A I get the number 255 on the Serial Monitor.  And when I send the letter B I get the same number, 255.  Any letter I send I get 255...

I can't make my led go on and off...

That is my code on the Arduino:

int Led = 0;  // variavel que recebe a informação do bluetooth

       

void setup() {
 
  Serial.begin(9600);// Inicializa a serial
  pinMode(13, OUTPUT);
  //Serial.flush();
 
}

void loop() {
 /*
  Serial.flush();
  delay(500); //Espero meio segundo
  Led = Serial.read(); // Recebe o valor via bluetooth
  delay(500); //Espero meio segundo
  */
  //if (Serial.available() > 0) {
       Led = Serial.read(); // Recebe o valor via bluetooth
       delay(500); //Espero meio segundo

                // say what you got:
       Serial.print("I received: ");
       Serial.println(Led, DEC);
  //}
  if (Led == 255){
    digitalWrite(13, HIGH);
  }
  else if (Led == 254) {
    digitalWrite(13, LOW);
  }
}

I am using three diferent types of apps on the Android: Blueserial, S2Terminal for Bluetooth and ITEAD BT.

Can anyone help me ?

Thanks !

thiagobarbosa


Hello,

I tried your codes but I can't seem to turn ON/OFF the led using your writeData(). I think arduino does not receive the value from android. Please can you help me figure it out. By the way. Here's my sketch:

int led = 13;
char inbyte = '0';
void setup() {
  Serial.begin(9600);
 pinMode(led, OUTPUT);
 digitalWrite(led, LOW);
}

void loop() {
 
if (Serial.available() > 0)
 {
   inbyte = Serial.read();
   if (inbyte == '0')
   {
     //LED off
     digitalWrite(led, LOW);
   }
   if (inbyte == '1')
   {
     //LED on
     digitalWrite(led, HIGH);
   }
 }
}
I'm having the same problem here =/

voquang98760

It might be a bit late, but the code goes in your Main Activity at least that's where I put it.
If you want to learn more about Android Development, here's a pretty nice video tutorial :
http://thenewboston.org/list.php?cat=6

The website covers lots of programming languages.
(I don't own this website, nor i'm related to it, I just find it very good and pretty complete at least to start)

thiagobarbosa

Can someone share an Arduino code that worked with this Android code?


Atwater88

Thanks for the post.
I will also try this hope i will learn new things.It's a interesting concept.

sadanandteggi

Hi please find another nice article on this
http://knowledge-cess.com/arduino-android-interfacing-example-code-and-troubleshooting/

sadanandteggi

Hi please find another nice article on this
http://knowledge-cess.com/arduino-android-interfacing-example-code-and-troubleshooting/

abhikul22

Hey,you can try this article to connect arduino with android using bluetooth

https://techwithabhi.wordpress.com/2015/06/10/control-arduino-using-bluetooth-with-android-app/

Go Up