from pybricks.hubs import TechnicHub
from pybricks.pupdevices import Motor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch

#GBC 45 Stunt Circus - Hub2
hub = TechnicHub()

#Initialize motors
motor_elevatorlift = Motor(Port.D) #Yellow
motor_ball_loader = Motor(Port.B) #Green

#Start loop
while True:
	#First run Elevator to the top to dump all the GBC Balls
	#Syntax is (Speed, Time ms, Then, Wait)
	try:
		motor_elevatorlift.run_time(3000, 10000, Stop.HOLD, True)
		motor_elevatorlift.run_time(-3000, 8000, Stop.HOLD, True)
	except:
		pass

	wait(2000)
	#Loads 9 GBC Balls in the Elebator module
	try:
		for count in range(9):	
			motor_ball_loader.run_angle (3000, 120, Stop.HOLD, True)
			motor_ball_loader.run_angle (3000, -120, Stop.HOLD, True)
	except:
		pass
	
	wait(2000)