File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 11# The program doesn't work without this. Not sure why.
2+ from time import sleep
23from ev3dev2 .motor import *
34from ev3dev2 .sensor .lego import *
45from ev3dev2 .sensor import *
@@ -79,9 +80,21 @@ def __init__(self, filename):
7980 self .AuxMotor1 = eval (conf .get ('AuxMotors' , 'AuxMotor1' ))
8081 self .AuxMotor2 = eval (conf .get ('AuxMotors' , 'AuxMotor2' ))
8182
82- # Instantiate the auxillary motor objects (only if motors are connected)
83- #self.m1 = MediumMotor(self.AuxMotor1)
84- #self.m2 = MediumMotor(self.AuxMotor2)
83+ # Instantiate the auxillary motor objects, checking if they are connected first.
84+ if self .AuxMotor1 is not None :
85+ try :
86+ self .m1 = MediumMotor (self .AuxMotor1 )
87+ except :
88+ print ("Aux Motor 1 Not Connected!" )
89+ self .spkr .beep ('-f 220' )
90+ if self .AuxMotor2 is not None :
91+ try :
92+ self .m2 = MediumMotor (self .AuxMotor2 )
93+ except :
94+ print ("Aux Motor 2 Not Connected!" )
95+ self .spkr .beep ('-f 220' )
96+ sleep (0.3 )
97+ self .spkr .beep ('-f 220' )
8598
8699
87100 # Instantiate the sensor objects
You can’t perform that action at this time.
0 commit comments