How to clear Bluetooth Buffer

Hello everyone,

I own a 'Sparkfun´s Bluetooth Mate Gold'. Now I want to drive a DC-Motor using the BT-Communication.
When I send a short command like an "w" it turn right for a short time.
BUT when I hold the "w"-button as long as about 2sec, it turns right for more than 10seconds and not for 2!!!

I think the problem is the Bluetooth-Buffer. Is there a way to clean it or to drive the motor for exactly that time, i hold the keyboard-button?

Greetings
K86

When I send a short command like an "w" it turn right for a short time.

Using what to send the data?

Using what code on the Arduino?

The communication between the PC and the bluetooth device and between the bluetooth device and the Arduino is serial. If you send a letter over and over as long as a key is held down, you will be sending lots of letters. You will need to receive and read all of them before you can quit acting on them.

Far better to send one code when a key is pressed and another when a key is released. Like, send 'a' when the a key is pressed, and send 'A' when it is released.

Then, the Arduino can start something happening when it gets a lower case letter, and stop it when it gets an upper case letter.

PaulS:

When I send a short command like an "w" it turn right for a short time.

on most phones, it will repeat "w" and send it as an 8 bit byte over and over....

so your buffer fills up with "wwwww" etc and that's what you'll get.

YourSerial.flush();

will empty the buffer.

YourSerial.flush();

will empty the buffer.

That depends on what version of the IDE you are using. On 1.0+, it does not.