Here's your sketch, to save trouble for the other reviewers ...
#include <SoftwareSerial.h>
SoftwareSerial btSerial(2, 3); // RX, TX
int in = A0;
void setup() {
// put your setup code here, to run once:
Serial.begin(38400);
btSerial.begin(38400);
pinMode(in, INPUT);
pinMode(10, INPUT); // Setup for leads off detection LO +
pinMode(11, INPUT); // Setup for leads off detection LO -
}
void loop() {
// put your main code here, to run repeatedly:
if ((digitalRead(10) == 1) || (digitalRead(11) == 1)) {
Serial.println('!');
}
else {
float val = analogRead(in);
Serial.println(val);
}
//Wait for a bit to keep serial data from saturating
delayMicroseconds(1000);
}
I marked the important parts in bold.
The default connection speed is usually 9600 bps.
Will this fast 4x speed connect okay? Maybe.
You do a println('!') but don't check in AI2 for that in your plotting math.
You do a println() of a float value, but do a readBytes in AI2.
AI2 does not know to assemble and decode the println text back into a number.
Instead, use an AI2 BT delimiter of 10 (line feed) and BT read text to get complete transmissions of the text form of the number:
Use println() to separate messages when you transmit.
Set Delimiter = 10 in BlueTooth Designer.
Check for Bytes Available > 0 in blocks,
but then request -1 bytes to get only full messages.
Your sending delay is 1000 microseconds = 1 millisecond.
AI2 can't process that quickly.
AI2 must read twice as often as your hardware sends, to avoid choking.
Adjust your Clock.Timer accordingly (20 ms?) and your .ino delay() longer (30000 uS = 30 ms?)
Guard your AI2 plotting math to excluded non-numeric messages (like '!')
ABG