How to setup Processing for Android to receive and send Serial communication over bluetooth ?

edited January 2016 in Android Mode

How to setup Processing for Android to receive and send Serial communication over bluetooth ? I want to have a serial communication between Arduino and Processing sketch running on my Nexus phone. Processing IDE ver 3.0.b6 Android SDK API: 5.1.1 .

Answers

  • I'm following this tutorial.. and till now I've had no problem till( Actually had one but solved it with an import -- actually by following thread here in the forum only).. Android/Processing Sketch 4: DiscoverBluetooth section.. I'm getting two errors(Attached in the picture)..

    After looking around it seems people had no problems from Eclipse.. But I want to stick to the IDE..

    Can anyone help?

  • edited January 2016 Answer ✓

    @dattasaurabh82===

    -your tutorial is for processing2: you are with P3, so you are in a fragment extending PApplet; you have to modify your code according to the fragment class...

    • or you can use ketai lib for bluetooth if it has been updated for P3

    • or use P2!

  • I was hoping to use Ketai for Bluetooth Serial .. But I don't know how to do that .. can you show me a simple example @akenaton ? I'm using HC-06 and Arduino Uno from Hardware side. So you can use just some pseudo MAC address for the Bluetooth module..

  • Answer ✓

    hello, I tried this method and it works: prof-takaya.blogspot.it/2013/02/connecting-android-and-arduino-by.html and recalls in "sketch permission" to check the two lines bluetooth

  • I'll take a look here .. Thanks @camperos

  • Yes It works. Thanks . But I first upgraded the Android mode on the Processing and also is now using ver 3.0.1.. Don't forget the sketch permissions (It's also commented in code as well to not forget)

  • SO Now I'm able to communicate as an example I was testing send send potentiometer readings from Arduino to Processing in App.. This is the part of the Arduino Loop where it's sending the data to Serial.

    void loop() { doAverage(trimPotPin); mappedVal = map(average, trimPotMin, trimPotMax, 0, 255); //Send data only if the values have changed. if (mappedVal != prevVal) { mySerial.println(mappedVal); } prevVal = mappedVal; delay(10); }

    Full Arduino Code

    And here's my Processing code:

    I was imagining it to be set at the given position of text and the value changing in time when I rotate my pot, but instead it keeps jumping and it seems the data is longer shorter(I don't know why does it appear on the app below each other)

Sign In or Register to comment.