プログラムを実行すると下記のようなエラーが起こります。
Trace (most recent call last):
File ”/home/pi/Desktop/0901.py", Line 389
elif stopped
^
SyntaxError: invalid syntax
Python
1try: 2 while True: 3 if stopped and runtime > 0: 4 sys.stdout.write(blanks) 5 sys.stdout.write("Timer stopped: %i seconds\r" % runtime) 6 sys.stdout.flush() 7 8 accel_data = mpu.get_accel_data() 9 #x_angle = util.get_x_rotation(accel_data['x'], accel_data['y'], accel_data['z']) 10 y_angle = util.get_y_rotation(accel_data['x'], accel_data['y'], accel_data['z']) 11 12 if y_angle < normalMin: 13 motor.setDirection("stop") 14 else: 15 motor.setDirection("forward") 16 if y_angle >= mediumMin and highMin > y_angle: 17 motor.setPower("MEDIUM") 18 elif y_angle >= highMin: 19 motor.setPower("HIGH") 20 #sys.stdout = open("log.txt" , "w") 21 #print("Y_ANGLE", y_angle) #and ("X_ANGLE", y_angle) 22 #print("Y", y_angle) 23 #print( now) 24 25 #print(now.date()) 26 now = datetime.datetime.now() 27 print(now.strftime("\t %Y-%m-%d \t %H:%M:%S.%f")) 28 #print ("%0.2d:%0.2d:%0.2d" % (now.hour, now.minute, now.millis)) 29 #print(millis) 30 #print(process_time) 31 #print( x_angle) 32 accel_data = mpu.get_accel_data() 33 print("X", accel_data['x']) 34 #print(accel_data['y']) 35 print("Y", y_angle) 36 print("Z", accel_data['z']) 37 gyro_data = mpu.get_gyro_data() 38 print("Gx", gyro_data['x']) 39 print("Gy", gyro_data['y']) 40 print("Gz", gyro_data['z']) 41 # #print("Ax:{:.4f}\tAy:{:.4f}\tAz:{:.4f}\tGx:{:.4f}\tGy:{:.4f}\tGz:{:.4f} ".format(accel_data['x'], accel_data['y'], accel_data['z'], gyro_data['x'], gyro_data['y'], gyro_data['z'])) 42 elif stopped: 43 sys.stdout.write(blanks) 44 sys.stdout.write("Touch enter to start!\r") 45 sys.stdout.flush() 46 else: 47 sys.stdout.write(blanks) 48 sys.stdout.write("Timer running: %i seconds\r" % (runtime + (time.time() - start))) 49 sys.stdout.flush() 50 time.sleep(0.1) 51 52 53 54finally: 55 #self.stop() 56 sys.stdout.close() 57 motor.clean() 58 time.sleep(0.5) 59 60atexit.register(exitHandler) 61
回答1件
あなたの回答
tips
プレビュー