Mouse keep alive

Antennas:
That is all well and good.....Except I do not know how to do that. If I did I wouldn't have needed to ask why it won't stop moving.

Write a function that moves the mouse as you want when you call it.

Write code to call that function at regular intervals. Blink without delay shows you how to run code at regular intervals.

Thanks John. I mean really, THANKS! I took your very helpful advice and example and made it do what I want. Whoo Hoo...

It does what I want, the only thing is it seems to have an issue with timing. It does the right time but then seems to double it. I suspect I don't have something in just the right spot to reset the timer. It doesn't move every two seconds regularly. What do you think is causing that??

Here is what I have now....

/* Buttons to USB Keyboard Example

   You must select Keyboard from the "Tools > USB Type" menu

   This example code is in the public domain.
*/

#include <Bounce.h>
unsigned long wait;
// Create Bounce objects for each button.  The Bounce object
// automatically deals with contact chatter or "bounce", and
// it makes detecting changes very simple.
Bounce button8 = Bounce(8, 10);
Bounce button9 = Bounce(9, 20);

// int waitTime

void setup() {
  
  pinMode(8, INPUT_PULLUP);
  pinMode(9, INPUT_PULLUP);
  Mouse.begin();
}

void loop() {
  // Update all the buttons.  There should not be any long
  // delays in loop(), so this runs repetitively at a rate
  // faster than the buttons could be pressed and released.
  button8.update();
  button9.update();
      
  if ((millis()- wait) >= 2000)  // for cleared testing and quicker measuring 
// Call the mouse to move
       {
        Mouse.move(2,2,0);
        //delay(25);
        Mouse.move(0,0,0);
        wait=millis();
       }
       
      // Check each button for "falling" edge.
    // falling = high (not pressed - voltage from pullup resistor)
  //           to low (pressed - button connects pin to ground)
    
  if (button8.fallingEdge()) {
    Keyboard.println("B8 press");
  }
  if (button9.fallingEdge()) {
    Keyboard.println("PASSWORD!");
  }
}

Thanks John, Riva and Peter. I think I have it now. Peter I still don't quite have a grasp on some of the concepts on the blink without delay, but I'll keep working on it!!

Andrew