No, the second method is to avoid (but even then not always) confusion about the name.
Using the module name has never failed for me.
my module name BT04-A and works with sliders sketch
my module name BT04-A and works with sliders sketch even with terminal worked both send receive
So using this name as the device_name works with the code above?
i did not try your last code yet but it works with other sketch you gave me for the sliders
but sure i change the name of module from HC-05 to BT04-A inside the sketch
i well try this and back to you with the result
and great thanks for you
Don’t put spaces between the quotations!
Which one? I’ve posted so many.
this works and control arduino
import ketai.net.bluetooth.*;
import controlP5.*;
import android.os.Bundle;
ControlP5 cP5a;
ControlP5 cP5b;
String device_name = "BT04-A";
//String device_mac = "40:45:DA:00:25:05";
KetaiBluetooth bt;
void setup() {
cP5a = new ControlP5(this);
cP5a.addSlider("CYCLE_TIME", 999, 1999,999, 10, 10, 255, 35);
cP5b = new ControlP5(this);
cP5b.addSlider("PULSE", 55, 455, 55, 10, 55, 255, 35);
bt.getPairedDeviceNames();
bt.start();
//bt.connectDevice("40:45:DA:00:25:05");
bt.connectToDeviceByName(device_name);
}
void draw() {
}
void controlEvent(ControlEvent theEvent) {
if (theEvent.isController()) {
print("control event from : "+theEvent.getController().getName());
println(", value : "+theEvent.getController().getValue());
if (theEvent.getController().getName()=="CYCLE_TIME") {
int val1 = int(theEvent.getController().getValue());
send("a" + val1+"\n");
}
if (theEvent.getController().getName()=="PULSE") {
int val2 = int(theEvent.getController().getValue());
send("b" + val2+"\n");
}
}
}
void send(String str) {
byte[] data = str.getBytes();
//bt.write(device_mac, data);
bt.writeToDeviceName(device_name, data);
//OscMessage m = new OscMessage(str);
//bt.broadcast(m.getBytes());
}
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bt = new KetaiBluetooth(this);
}
Really?
The integer val1 is converted to a string how?
send("b" + val1 +"\n");
void send(String str) {
byte[] data = str.getBytes();
bt.writeToDeviceName(device_name, data);
}
this is the arduino code`
void bob() {
if (Serial.available() >= 2)
{
int value2;
char command = Serial.read();
switch (command)
{
case 'a': value2 = Serial.parseInt();
CYCLE_TIME = value2;
{
break;
case 'b': value2 = Serial.parseInt();
TX_PULSE = value2;
break;
}
hi
this sketch keeps stop
if i remove this lines it compile with blue screen but without action
import ketai.net.bluetooth.*;
import android.os.Bundle;
String device_name = "BT04-A";
String Str;
KetaiBluetooth bt;
void setup() {
fullScreen();
orientation(PORTRAIT);
bt.getPairedDeviceNames();
bt.connectToDeviceByName(device_name);
bt.start();
textSize(60); /// this line
textAlign(CENTER); //// this line
}
void draw() {
background(0, 0, 200);
text(Str, width/2, height/2);/// this line
}
void onBluetoothDataEvent(String who, byte[] data) {
Str = new String(data);
println(Str);
}
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bt = new KetaiBluetooth(this);
}
But did it println(); a string to the console?
i just link the bluetooth module with out data still prepare the arduino
I don’t understand this.
i am not sure if it println(); a string to the console i well try again and see
Nice!..
i need a few help more if you kind
this is simple arduino code reading from potentiometer
void setup() {
// initialize the serial communication:
Serial.begin(9600);
}
void loop() {
// send the value of analog input 0:
Serial.println(analogRead(A0));
// wait a bit for the analog-to-digital converter to stabilize after the last
// reading:
delay(2);
}
and this is the processing sketch its working with serial i need to send it with bluetooth how to do it ??
import processing.serial.*;
Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph
float inByte = 0;
void setup () {
// set the window size:
size(400, 300);
// List all the available serial ports
// if using Processing 2.1 or later, use Serial.printArray()
println(Serial.list());
// I know that the first port in the serial list on my Mac is always my
// Arduino, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);
// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');
// set initial background:
background(0);
}
void draw () {
// draw the line:
stroke(127, 34, 255);
line(xPos, height, xPos, height - inByte);
// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(0);
} else {
// increment the horizontal position:
xPos++;
}
}
void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');
if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
inByte = float(inString);
println(inByte);
inByte = map(inByte, 0, 1023, 0, height);
}
}
i try many times but could not make it