All pastes #900981 Raw Edit

Stuff

public text v1 · immutable
·published 2008-02-12 09:25 UTC
rendered paste body
import java.util.*;
import listeners.*;
import com.phidgets.*;
import com.phidgets.event.*;

public class ServoTimerTask extends TimerTask {
		
	public void run() {
		try {
			ServoPhidget servo = new ServoPhidget();
		} catch (PhidgetException e) {
			System.out.println(e);
		}
		
		servo.openAny();
		System.out.println("waiting for Servo attachment...");
		servo.waitForAttachment();
		
		servo.addAttachListener(new MyAttachListener());
		servo.addDetachListener(new MyDetachListener());
		servo.addErrorListener(new MyErrorListener());
		
		servo.setPosition(0, 15.0);
		
		Thread.sleep(10);
		
		servo.setPosition(0, 50.0);
		
		Thread.sleep(10);
		
		servo.setPosition(0, 15.0);
		
		System.out.println("Outputting events.  Input any character to stop.");
		
		System.in.read();
		System.out.print("Closing...");
		servo.close();
		servo = null;
		System.out.println("Closed.");
	}
}