[Solved] Attack3 Joystick buttons to turn on LEDs on Arduino?

See frameRate and frameRate() in the help. Let’s find out how often your draw is running. Try this just before end of draw function

if (frameCount % 120 == 0){print frameRate(); print " ");}

At the moment your sketch is repeatedly reading the joystick and transmitting to Ard 60 times/sec if it can keep up with that. I would put frameRate(20); just after the size statement. Then we know draw is running every 50 mS and we can use counters to control when things happen.

At the start of draw you are sending joystick x and y to Ard. If but3,4,5 are pressed you send different x values just after. I think that’s the reason for the mis-behaviour and the delays stop some of it. What do you want the x servo to do? Something like 'follow the x joystick except if but3 is pressed go to min then max, and if but4 is pressed go to max, but3 to min? After those specific movements go back to following the joystick after a set time? Does the servo have position signals back to the Ard? (We could put something on screen that shows where you want the servo, and where it is.)

1 Like