Loading...
Logo
Processing Forum

Bluetooth Arduino

in Android Processing  •  7 months ago  
Hello friends, I first want to apologize for my English.

recently I started to use the library Ketai and could link it with arduino (I managed to turn on and off an LED) now, not just want to turn on the LED, also want to control the brightness using PWM. I created an application but I can not send the values ​​to be read by the arduino. the application consists of a potentiometer knob. PLEASE if any of you has done something similar, I would greatly appreciate YOUR HELP.

the error: broadcast(byte[]) int ketai.net.bluetooth.KetaiBluetooth cannot be appiled to (int)

thanks.
 

Replies(5)

Re: Bluetooth Arduino

7 months ago
yep,
I think you are trying to send a int instead a byte, try to send byte like this :

Processing code :

Copy code
  1. byte[] data2 = {
  2.         's', 'w', 'i', 't', 'c', 'h', '\r'
  3.       };

  4.       bt.broadcast(data2);
and receive brodcast like this :

Arduino code

Copy code
  1. String strInput = ""; // buffer for incoming packet
  2. String strCompare = "switch";
  3. char chByte = 0; 


  4. void setup() {
  5.   Serial3.begin(115200); //serial 3 of mega board
  6.   Serial.begin(9600);
  7.   pinMode(9,OUTPUT);

  8. }
  9. void loop()

  10. {
  11. while (Serial3.available() > 0)
  12.     {
  13.       // get incoming byte:
  14.       chByte = Serial3.read();
  15.       if (chByte == '\r')
  16.       {
  17.         Serial.println("strInput");
  18.         //compare input message
  19.         if(strInput.equals(strCompare))
  20.         {
  21.           digitalWrite(9, HIGH);
  22.           Serial.println("LED is ON");
  23.           delay(1000);
  24.           digitalWrite(9, LOW);
  25.           Serial.println("LED is OFF");         
  26.         }
  27.         //reset strInput
  28.         strInput = "";
  29.       }
  30.       else{
  31.         strInput += chByte;
  32.       }

  33.     }

  34. }




could you send us your code ?
Hi, thanks for the answer. I used this code to turn on an LED, but not exactly what I thought as my idea is to send values ​​(numbers) and do not know how. My app consists of a scroll bar and the values ​​increase as the bar goes up, then those values ​​will be sent and read by the arduino. MY IDEA LIKE TO KNOW IF THERE IS CORRECT OR OTHERWISE. THANKS

Re: Bluetooth Arduino

7 months ago
you must send bytes and not numbers, then you put in shape with Arduino

Re: Bluetooth Arduino

7 months ago
hello friends, I tell them that it was solved only convert the integers to byte .. Processing and Arduino have the advantage of making it easy. thanks anyway for your assistance

Re: Bluetooth Arduino

7 months ago
Hi  danieloqu.....

I want to control video playing on android device by the arduino.
How you connect arduino to procesing on android device.
Need your suggestions