Hi. I'm pretty new to this so apologies if this is a no-brainer. However, I've looked around and cant find a solution to this...
The background/setup is this: I have an Arduino which has a bunch of L9110 motor drivers connected to it for 7 motors. Each one will be controlled via ASCII values sent down the serial port using a Processing GUI rather than the Arduino serial monitor. I want the motor to run while the relevant keyboard key is pressed AND also while the relevant GUI button is pressed with the mouse (so, equal functionality for both). So far the program works fine when sending key presses from the keyboard - essentially a stream of ASCII characters are sent to the Arduino which results in a series of pulses to the motor controller and this is fine. The mouse press also works fine to send a single character (and thus a pulse) to the motor controller. But I need it to send a continuous stream while the mouse is pressed.
The code for the mouse is below, with explanations for the variables shown first (and I've deleted the end curly brackets for simplicity):
RButton is the class for each motor direction button (2 for each motor, ie forward and reverse). So 14 buttons in the array. Each object in the array is called rButton isMouseOver is a boolean check to see if the mouse is over the button coordinates chgButtonCol is the boolean variable which changes the colour of the button when it is pressed arduinoPort is the variable for the serial port of my Arduino assKey is the ASCII character associated with each button :-D
void mousePressed() {
for(RButton currentButton : rButton) {
if(currentButton.isMouseOver() == true) {
currentButton.chgButtonCol = true;
arduinoPort.write(currentButton.assKey);
delay(50);
void mouseReleased() {
for(RButton currentButton : rButton) {
currentButton.chgButtonCol = false;
Thanks in advance for your help...