bluetooth and processing
in
Integration and Hardware
•
1 year ago
Hello Everyone,
I am currently working on a GUI which involves bluetooth with processing.
I am thinking of having two purposes for the bluetooth involvement.
The First Purpose
It searches, it retrieves and it saves whenever bluetooth is activated.( in this case, the button is being pressed on the GUI).
I have read through the examples by extrapixels for bluetooth with processing but I only manage to get the searches function to work. Below are my codes.
import bluetoothDesktop.*;
import controlP5.*;
ControlP5 controlP5;
Bluetooth bt;
PFont btfont;
String msg = "Blue Tooth Inactive!";
void setup()
{
size(640,480);
background(0);
smooth();
frameRate(30);
controlP5 = new ControlP5(this);
controlP5.addButton("BlueTooth", 5, 90, 10, 50, 20);
controlP5.setAutoDraw(false);
btfont = createFont("timesnewsroman", 15);
textFont(btfont);
}
void draw()
{
//Bluetooth
fill(255);
text(msg, 150, 25);
gui();
}
void gui()
{
controlP5.draw();
}
void BlueTooth()
{
try
{
bt = new Bluetooth(this, 0x0003); // RFCOMM
bt.find(); // Start finding the service
msg = "searching...";
}
catch (RuntimeException e)
{
msg = "error. is your bluetooth on?";
println(e);
}
}
The Second Purpose
It will upload and download file continously. I do understand that this can be achieved if I were to put an infinite loop in my codes such as a while loop, or for loop. However, I did not quite understand where to place such loop as I am a total beginner to programming not forgetting to mention processing as well.
Thank you in advanced:)
Regards,
hanny
1