Example #1
0
            time.sleep(1.7 + 2)
        else:
            if t1 <= 5.1:
                time.sleep(t1 - 1.7 + 2)
            else:
                time.sleep(1.7)
                if not stop and not noCaneReached:
                    cutter.ChangeDutyCycle(2)
                time.sleep(1.7)
                if not stop and not noCaneReached:
                    cutter.ChangeDutyCycle(30)
                time.sleep(t1 - 5.1 + 2)

    return comd
try:
    ch0 = RCServo()

except RuntimeError as e:
    print("Runtime Exception %s" % e.details)
    print("Press Enter to Exit...\n")
    readin = sys.stdin.read(1)
    exit(1)


def RCServoAttached(e):
    try:
        attached = e

        print("\nAttach Event Detected (Information Below)")
        print("===========================================")
        print("Library Version: %s" % attached.getLibraryVersion())
from Phidget22.Phidget import *
from Phidget22.PhidgetException import *
from Phidget22.Devices.RCServo import *
from Phidget22.Devices.DigitalOutput import *

#Create an RCServo object
try:
    userMotor = RCServo()
    randomMotor = RCServo()
except RuntimeError as e:
    print("Runtime Error: %s" % e.message)
#Each object needs a serial number so that the Phidget knows what that is
try:
    userMotor.setDeviceSerialNumber(393344)
    randomMotor.setDeviceSerialNumber(393344)
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))


def onAttachHandler(e):
    print("Phidget attached!")


userMotor.setOnAttachHandler(onAttachHandler)
randomMotor.setOnAttachHandler(onAttachHandler)
#Set the channel (the motors need to be plugged in the same channel)
userMotor.setChannel(1)
randomMotor.setChannel(7)
#Open the channel
try:
    userMotor.openWaitForAttachment(5000)
Example #3
0
if platform.system() == "Darwin":
    SWITCH_MODE_BTN = 10
    STOP_BTN = 12
    STEER_AXIS = 0
    THROTTLE_AXIS = 5
    GEAR_CHANGE_AXIS = 3
elif platform.system() == "Linux":
    SWITCH_MODE_BTN = 8
    STOP_BTN = 1
    STEER_AXIS = 0
    THROTTLE_AXIS = 5
    GEAR_CHANGE_AXIS = 4

try:
    servo_ch = RCServo()
    motor_ch = DCMotor()
except RuntimeError as e:
    print("Runtime Exception, ", e)
    print("Press Enter to Exit...\n")
    readin = sys.stdin.read(1)
    exit(1)

def RCServoAttached(self):
    try:
        attached = self
        print("\nAttach Event Detected (Information Below)")
        print("===========================================")
        print("Library Version: %s" % attached.getLibraryVersion())
        print("Serial Number: %d" % attached.getDeviceSerialNumber())
        print("Channel: %d" % attached.getChannel())
Example #4
0
 def __init__(self, SERVO_HUB, SERVO_PORT, SERVO_CHANNEL):
     servo_ch = RCServo()
     servo_ch.setDeviceSerialNumber(SERVO_HUB)
     servo_ch.setHubPort(SERVO_PORT)
     servo_ch.setChannel(SERVO_CHANNEL)
     super(ServoMotorDevice, self).__init__(servo_ch)
Example #5
0
def main():
    #Create your Phidget channels
    rcServo0 = RCServo()
    rcServo1 = RCServo()

    #Set addressing parameters to specify which channel to open (if any)
    rcServo0.setChannel(0)
    rcServo1.setChannel(1)

    #Assign any event handlers you need before calling open so that no events are missed.

    #Open your Phidgets and wait for attachment
    rcServo0.openWaitForAttachment(5000)
    rcServo1.openWaitForAttachment(5000)

    #Do stuff with your Phidgets here or in your event handlers.
    rcServo0.setTargetPosition(90)
    rcServo0.setEngaged(True)
    rcServo1.setTargetPosition(90)
    rcServo1.setEngaged(True)

    kb_controller = ServoKeyboardControl()
    kb_controller.keyboard_control()

    try:
        input("Press Enter to Stop\n")
    except (Exception, KeyboardInterrupt):
        pass

    #Close your Phidgets once the program is done.
    rcServo0.close()
    rcServo1.close()
Example #6
0
#Add Phidgets Library
from Phidget22.Phidget import *
from Phidget22.Devices.RCServo import *
#Required for sleep statement
import time

#Create
servo = RCServo()

#Address
servo.setChannel(0)

#Open
servo.openWaitForAttachment(1000)

#Configure voltage based on servo attached (search datasheet online)
servo.setVoltage(RCServoVoltage.RCSERVO_VOLTAGE_6V)

#Initialize
servo.setTargetPosition(0)
servo.setEngaged(True)

working = True
while(working):
    targetPos = int(input("Enter number between 0-180. Enter -1 to exit\n"))
    if(targetPos >= 0):
        servo.setTargetPosition(targetPos)
    else:
        working = False

print("Program Exiting")
from Phidget22.Phidget import *
from Phidget22.PhidgetException import *
from Phidget22.Devices.RCServo import *

try:
    ch = RCServo()
except RuntimeError as e:
    print("Runtime Error: %s" % e.message)
try:
    ch.setDeviceSerialNumber(393344)
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))


def onAttachHandler(e):
    print("Phidget attached!")


ch.setOnAttachHandler(onAttachHandler)
ch.setChannel(7)
ch.openWaitForAttachment(5000)

myPos = 35
#ch.setEngaged(True)
#ch.setAcceleration(25.0)
#ch.setTargetPosition(myPos)