Here's a sample of our code using the robot class to wake/sleep the computer when motion is detected by a sensor connected to an Arduino microcontroller. We used a counter as a substitute example for what would be incoming serial data from a sensor connected to the Arduino, so that every time the counter reaches 100, the mouse moves.

++++++++++++++++++++++++++++

//ROBOT CLASS WAKING & SLEEPING COMPUTER

//Tali Blankfeld & Suzanne Kirkpatrick

//import libraries

//use robot class to wake computer up/put it to sleep

//trigger robot class w/ incoming serial data from motion sensor (using a counter in this example)

import java.awt.Robot;

import java.awt.event.InputEvent;

Robot r;

int xCoor = 400;

int yCoor = 0;

int count = 0;

int counter = 0;

void setup() {

  background(255);
  size(950, 500); 

 //create robot instance - our friend Erica told us we should include this part!

try {

    r = new Robot();
  }
  catch (Exception e) {
    println("error");
  }

}

void draw() {

  //trigger mouseMove

 //   if(monkey passes in front of motion detector) 
 // {
   // if (button pressed ==false) {

//r.mouseMove(x coord, y coord);

  //  }

//}

//substitute counter for sensor

counter++;

println(counter);

if(counter == 100){

 counter = 0;
 count++;

r.mouseMove(800/count, 300/count); } }

void keyPressed(){

 if (key == CODED) {
    if (keyCode == UP) {
      yCoor --;

r.mouseMove(xCoor, yCoor);

    } else if (keyCode == DOWN) {
      yCoor++;

r.mouseMove(xCoor, yCoor);

    } 
 }

}