Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motor test fix #47

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 35 additions & 47 deletions Code/Server/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -96,7 +91,6 @@ def test_Infrared():
except KeyboardInterrupt:
print ("\nEnd of program")


from servo import *
pwm=Servo()
def test_Servo():
Expand All @@ -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():
Expand Down Expand Up @@ -152,32 +145,27 @@ 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':
test_Motor()
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()