Bluetooth to bluetooth mate loss of data
hello all,
able 2 bluetooth mates , 2 arduino pro minis communicating through serial windows using suggested code sparkfun on each arduino
this worked sending text , forth, next step able send commands , light led on other arduino. found tutorial here used led light up: http://www.instructables.com/id/serial-communications-with-arduino/step4/serial-led-code/
i used code led light up, , turn off depending on or b entered serial window of sending arduino
this working, instead of typing "a" or "b" decided type in longer data see happen. noticed when type in word hello instance, receiving arduino serial display ello, or llo, or ell. @ point realized when typing "a" or "b", led not turn on or off @ first instance, have enter "a" several times led light.
@ point realized loosing data somehow sending arduino receiving. when used first set of code provided sparkfun there no data loss. using modified code getting data loss.
i have transmitting arduino broadcast status of 2 push buttons sending constant commands, rather transmit when button pushed instead of constant transmission.
see when mistake at?
thanks
able 2 bluetooth mates , 2 arduino pro minis communicating through serial windows using suggested code sparkfun on each arduino
code: [select]
#include <softwareserial.h>
int bluetoothtx = 2; // tx-o pin of bluetooth mate, arduino d2
int bluetoothrx = 3; // rx-i pin of bluetooth mate, arduino d3
softwareserial bluetooth(bluetoothtx, bluetoothrx);
void setup()
{
serial.begin(9600); // begin serial monitor @ 9600bps
bluetooth.begin(115200); // bluetooth mate defaults 115200bps
bluetooth.print("$"); // print 3 times individually
bluetooth.print("$");
bluetooth.print("$"); // enter command mode
delay(100); // short delay, wait mate send cmd
bluetooth.println("u,9600,n"); // temporarily change baudrate 9600, no parity
// 115200 can fast @ times newsoftserial relay data reliably
bluetooth.begin(9600); // start bluetooth serial @ 9600
}
void loop()
{
if(bluetooth.available()) // if bluetooth sent characters
{
// send characters bluetooth prints serial monitor
serial.print((char)bluetooth.read());
}
if(serial.available()) // if stuff typed in serial monitor
{
// send characters serial monitor prints bluetooth
bluetooth.print((char)serial.read());
}
}
this worked sending text , forth, next step able send commands , light led on other arduino. found tutorial here used led light up: http://www.instructables.com/id/serial-communications-with-arduino/step4/serial-led-code/
i used code led light up, , turn off depending on or b entered serial window of sending arduino
code: [select]
void loop()
{
if(bluetooth.available()) // if bluetooth sent characters
serial.print ((char)bluetooth.read());
inbyte = (char)bluetooth.read();
if(inbyte == 'a') { // byte 'a'
digitalwrite(13, high);
serial.println("led - on");
}
else if( inbyte == 'b'){// byte isn't 'a'
digitalwrite(13, low);
serial.println("led - off");
}
if(serial.available()) // if stuff typed in serial monitor
{bluetooth.print((char)serial.read());
}
}
this working, instead of typing "a" or "b" decided type in longer data see happen. noticed when type in word hello instance, receiving arduino serial display ello, or llo, or ell. @ point realized when typing "a" or "b", led not turn on or off @ first instance, have enter "a" several times led light.
@ point realized loosing data somehow sending arduino receiving. when used first set of code provided sparkfun there no data loss. using modified code getting data loss.
i have transmitting arduino broadcast status of 2 push buttons sending constant commands, rather transmit when button pushed instead of constant transmission.
see when mistake at?
thanks
quote
does see when mistake at?
it starts
with
your
poor
indenting.
use tolls + auto format make code presentable.
it's followed testing there @ least 1 byte read, , reading 2 or more bytes.
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Bluetooth to bluetooth mate loss of data
arduino
Comments
Post a Comment