joystick_pressed = 1
		
		if Joystick.get_button(6) == 0:
			joystick_pressed = 0
			

		stop = Joystick.get_button(0)
		if autoMode:
			#auto predict
			try:
				axis = prediction.predict_angle(steer_enhancer)
				
			except:
				axis = 0
			print(axis)
			SteeringWheel.set_angle(axis) # Sets the steering angle to the wheels
			DrivingMotor.Run(1)
		else:
			#manual override
			axis = Joystick.get_axis(0)
			start = Joystick.get_button(7)
			if start:
				SteeringWheel.set_angle(axis)
			DrivingMotor.Run(start)
		
		del Joystick
	sleep(0.001)

		
		
	pygame.event.get()

	if pygame.joystick.get_count() == 1: # 1
		Joystick = pygame.joystick.Joystick(0)
		Joystick.init()
		
		if Joystick.get_button(6) == 0:
			joystick_pressed = 0
			
		autoMode = Joystick.get_button(6)
		stop = Joystick.get_button(0)
			#manual override
		axis = Joystick.get_axis(0)
		start = Joystick.get_button(7)
		if start:
			SteeringWheel.set_angle(axis)
			if autoMode:
				i = i + 1
				if i % 10 == 0:
					 cap.capture(angle = axis*5, fram = int(i/10))
		DrivingMotor.Run(start)
		
		del Joystick
	sleep(0.001)

		
		

SteeringWheel.Stop()
del SteeringWheel
del DrivingMotor