I write program to control motor with wiring Pi's function,in this program do digital write (for example )40 time;
How can simulate write until key down after key up stop writing?in linux
isan:
now I want to do write until hold 'M' after release 'M' stop writing....
You can't easily do that with the Arduino Serial Monitor because what you do not want to happen is for a continuous stream of 'M's to be sent to the Arduino.
If you write a simple program on your PC using Python (or your favourite language) it can detect when a key goes down and send (say) an 'M' to start the motor moving and later detect when the key is released and send (say) and 'm' to tell the Arduino to stop the motor.
If you want to use the Serial Monitor I suggest you use 'M' to start the move and 'S' to stop the move.
no I want use C++ / C for this part I should use one key hold and release
can you explain more about this part you said:
it can detect when a key goes down and send (say) an 'M' to start the motor moving and later detect when the key is released and send (say) and 'm' to tell the Arduino to stop the motor.
isan:
can you explain more about this part you said:
I am assuming you mean that you want to write your PC program using C/C++. I'm afraid I am too lazy for that so I can only give general guidance.
The PC system will have events that trigger when a key is pressed and when it is released. In Python the Tkinter library has an onKeyPress() function. I presume there is an equivalent for C/C++.
The code in Reply #8 looks like it is Arduino code. You need PC code to deal with your problem and, as I said, I do not know enough about C/C++ on a PC to help you. I'm sure Google will have 1000s of answers.
And keyDown and keyUp do not depend on timing, they are events. Google "C++ keydown event" and see what you get