Keyboard Break-Codes

Hello everybody,

i want to drive my DC-Motor (via Arduino,Bluetooth<->Laptop) as long as i am pressing a button (W,S).
When i release the button it should stop. But the stored commands in my Bluetooth-Buffer are driving the motor again and again.
Is there a chance to send some Keyboard Break-Codes? So when i release the button, the motor stops.
e.g. something like this:

Serial.available();
value = Serial.read();

if(value == 'w') {
digitalWrite(8, HIGH);   //start motor
analogWrite(9, 100);    // set pwm to 100
}
if(value == '...breakcode of w...') {
digitalWrite(8, LOW);    // stop motor
analogWrite(9, 0);    // set pwm to 0
}

Greetings
K86

You are going about it all wrong. Send ONE character when the key is pressed. Send another when the ley is released. Send a 'A' for the a key being pressed, and 'a' when it is released, for example.

Do NOT send a steady stream of characters while the key is held down.

no matter if bluetooth or wired, you are sending serial commands.

Thus it's your laptop's software task to do low level keyboard handling to get keyup and keydown events and send appropriate messages to your arduino.

As Paul said a minute ago, I'd send different characters and only once, instead of eventually using some autorepeat mechanism while a key is pressed a long time.

Oh great idea. But how should i do that?
If i press the 'w'-button what could be send? I don´t get the code.
Especially when i am doing it with the !=-Function.

if(value!='w' || value!='s') {
digitalWrite(8, LOW);   
analogWrite(9, 0);
}

This is not correct i know :~

If i press the 'w'-button what could be send?

How about a 'w' when pressed and a 'W' when released?

Especially when i am doing it with the !=-Function.

Don't use not equal. You should have cases for 'w' and 'W' that do opposite things (turn motors on one way and off the same way).

Kelevra86:
i want to drive my DC-Motor (via Arduino,Bluetooth<->Laptop) as long as i am pressing a button (W,S).
When i release the button it should stop. But the stored commands in my Bluetooth-Buffer are driving the motor again and again.

You're holding the key down on the PC and the key presses are being sent via BlueTooth to the Arduino? What application are you using on the PC to do that?