Results 1 to 2 of 2

Thread: phidgets, Servos, and Java Help

  1. #1
    Newbie lee03's Avatar
    Join Date
    Feb 2005
    Posts
    19

    phidgets, Servos, and Java Help

    I have a 8/8/8 kit with sensors and a servo controller with the pan and tilt kit. I am trying to use the joystick sensor to control my pan and tilt kit. I have little experience with java, so could someone with experience direct me. The joystick has a method OnSensorChange that displays the sensor value, but the return type is void. I am tring to get the sensor values as they change and set that value as the motor position. more information on phidgets can be found @
    www.phidgets.com
    www.phidgetsusa.com
    here is the method:

    public void OnSensorChange(_IPhidgetInterfaceKitEvents_OnSenso rChangeEvent ke)
    {
    System.out.println("SensorChange: " + ke.get_SensorValue());

    }

    phid.SetMotorPosition(int (motor #),double(position));

    I am tring to take the ke.get_SensorValue() and set that as the motor position. Is this the way to do this?


    thanks

  2. #2
    Maximum Bitrate DeltaFX's Avatar
    Join Date
    Sep 2004
    Location
    France
    Posts
    499
    Thoses OnSomethingHappend function are triggers, they have no return type, they just detect somthing happend on hardware side. So use them to encapsulate what you want to be done.

    Now just add some math to convert joystick's value's range to servos' range before calling SetMotorPostion.

    Your function should look like this (no math inserted)

    public void OnSensorChange(_IPhidgetInterfaceKitEvents_OnSenso rChangeEvent ke)
    {
    phid.SetMotorPosition(int (motor #),double(ke.get_SensorValue()));

    }

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •