#need help with this code

4 messages · Page 1 of 1 (latest)

heavy panther
#

making a marble sorter using Python and vex code, I'll post the code I have now but I don't know how to make it so that I'm using a gear and I want it to have a set position and then return back to that position everytime it rotates to a different position based off of a light sensor

pastel gate
#

wher code

heavy panther
#

I’ll send it in tomorrow cause my code is on my pc

heavy panther
#

while True:
brain.screen.clear_screen()
brain.screen.set_cursor(1,1)

cup.spin(FORWARD)
cup.set_velocity(10, PERCENT)
gear.set_position(0, DEGREES)
spinner.set_velocity(10, PERCENT)
spinner.spin_for(REVERSE, 90, DEGREES)
wait(2.8, SECONDS)

midpoint = (-45 + 55) / 2 
optical_10.set_light(LedStateType.ON)
if optical_10.is_near_object() == 1: 

    if optical_10.hue() > -30 and optical_10.hue() < 30: #red
        servo_h.set_position(110, DEGREES)
        gear.spin_to_position(90, DEGREES)
        wait(.5, SECONDS)
        gear.spin_to_position(-90, DEGREES)

    elif optical_10.hue() > 210 and optical_10.hue() < 270: #blue 
        servo_h.set_position(110, DEGREES)
        gear.spin_to_position(120, DEGREES)
        wait(.01, SECONDS)
        gear.spin_to_position(-120, DEGREES)

    else:
        servo_h.set_position(midpoint, DEGREES)
        gear.set_position(0, DEGREES)

wait(.1, SECONDS)