diff --git a/Code/Server/test.py b/Code/Server/test.py index 694fbcbd..a8017764 100644 --- a/Code/Server/test.py +++ b/Code/Server/test.py @@ -19,53 +19,48 @@ def test_Led(): led.colorWipe(led.strip, Color(0,0,0)) #turn off the light print ("\nEnd of program") - - -from Motor import * -PWM=Motor() -def test_Motor(): +from Motor import * +PWM=Motor() +def test_Motor(): try: - PWM.setMotorModel(1000,1000,1000,1000) #Forward + PWM.setMotorModel(1000,1000,1000,1000) print ("The car is moving forward") time.sleep(1) - PWM.setMotorModel(-1000,-1000,-1000,-1000) #Back + PWM.setMotorModel(-1000,-1000,-1000,-1000) print ("The car is going backwards") time.sleep(1) - PWM.setMotorModel(-1500,-1500,2000,2000) #Turn left + PWM.setMotorModel(-1500,-1500,2000,2000) print ("The car is turning left") time.sleep(1) - PWM.setMotorModel(2000,2000,-1500,-1500) #Turn right - print ("The car is turning right") + PWM.setMotorModel(2000,2000,-1500,-1500) + print ("The car is turning right") time.sleep(1) - PWM.setMotorModel(-2000,2000,2000,-2000) #Move left - print ("The car is moving left") + PWM.setMotorModel(-2000,2000,2000,-2000) + print ("The car is moving left") time.sleep(1) - PWM.setMotorModel(2000,-2000,-2000,2000) #Move right - print ("The car is moving right") - time.sleep(1) - - PWM.setMotorModel(0,2000,2000,0) #Move diagonally to the left and forward - print ("The car is moving diagonally to the left and forward") + PWM.setMotorModel(2000,-2000,-2000,2000) + print ("The car is moving right") time.sleep(1) - PWM.setMotorModel(0,-2000,-2000,0) #Move diagonally to the right and backward - print ("The car is moving diagonally to the right and backward") - time.sleep(1) - PWM.setMotorModel(2000,0,2000,00) #Move diagonally to the right and forward - print ("The car is moving diagonally to the right and forward") + PWM.setMotorModel(0,2000,2000,0) + print ("The car is moving diagonally to the left and forward") time.sleep(1) - PWM.setMotorModel(-2000,0,-2000,0) #Move diagonally to the left and backward - print ("The car is moving diagonally to the left and backward") - time.sleep(1) - - PWM.setMotorModel(0,0,0,0) #Stop + PWM.setMotorModel(0,-2000,-2000,0) + print ("The car is moving diagonally to the right and backward") + time.sleep(1) + PWM.setMotorModel(2000,0,0,2000) + print ("The car is moving diagonally to the right and forward") + time.sleep(1) + PWM.setMotorModel(-2000,0,0,-2000) + print ("The car is moving diagonally to the left and backward") + time.sleep(1) + PWM.setMotorModel(0,0,0,0) print ("\nEnd of program") except KeyboardInterrupt: PWM.setMotorModel(0,0,0,0) print ("\nEnd of program") - from Ultrasonic import * -ultrasonic=Ultrasonic() +ultrasonic=Ultrasonic() def test_Ultrasonic(): try: while True: @@ -96,7 +91,6 @@ def test_Infrared(): except KeyboardInterrupt: print ("\nEnd of program") - from servo import * pwm=Servo() def test_Servo(): @@ -118,8 +112,7 @@ def test_Servo(): pwm.setServoPwm('0',90) pwm.setServoPwm('1',90) print ("\nEnd of program") - - + from ADC import * adc=Adc() def test_Adc(): @@ -152,15 +145,14 @@ def test_Buzzer(): except KeyboardInterrupt: buzzer.run('0') print ("\nEnd of program") - + # Main program logic follows: if __name__ == '__main__': - print ('Program is starting ... ') import sys if len(sys.argv)<2: print ("Parameter error: Please assign the device") - exit() + exit() if sys.argv[1] == 'Led': test_Led() elif sys.argv[1] == 'Motor': @@ -168,16 +160,12 @@ def test_Buzzer(): elif sys.argv[1] == 'Ultrasonic': test_Ultrasonic() elif sys.argv[1] == 'Infrared': - test_Infrared() - elif sys.argv[1] == 'Servo': - test_Servo() - elif sys.argv[1] == 'ADC': - test_Adc() - elif sys.argv[1] == 'Buzzer': - test_Buzzer() + test_Infrared() + elif sys.argv[1] == 'Servo': + test_Servo() + elif sys.argv[1] == 'ADC': + test_Adc() + elif sys.argv[1] == 'Buzzer': + test_Buzzer() elif sys.argv[1] == 'Rotate': car_Rotate() - - - -