All pastes #900987 Raw Edit

Stuff

public text v1 · immutable
·published 2008-02-12 09:38 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();
			
			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);
			
			try {
				Thread.sleep(10);
			} catch (InterruptedException e) {
				System.out.println(e);
			}
			
			servo.setPosition(0, 50.0);
			
			try {
				Thread.sleep(10);
			} catch (InterruptedException e) {
				System.out.println(e);
			}
			
			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.");
		} catch (PhidgetException e) {
			System.out.println(e);
		}
	}
}