|
老師,我用goto,直走程序沒問題但是他不會跳轉到S_Name執行轉彎程序,他還是一直前進
DO
If Distance1 =22 Then
MyMotor.ForwardAB(400,410)
PAUSE 500
ElseIf Distance2 <22 Then
MyMotor.ForwardAB(400,430)
PAUSE 500
ElseIf Distance1 >22 Then
MyMotor.ForwardAB(430,400)
ElseIf Distance1 >50 Then
Goto S_Name
Goto_Return:
MyMotor.ForwardAB(430,400)
PAUSE 500
End If
Loop
S_Name :
If Distance1 >50 Then
MyMotor.ForwardAB(410,0)
PAUSE 2000
MyMotor.ForwardAB(0,0)
PAUSE 500
MyMotor.ForwardAB(400,410)
PAUSE 2000
MyMotor.ForwardAB(0,0)
PAUSE 500
MyMotor.ForwardAB(410,0)
PAUSE 2000
MyMotor.ForwardAB(0,0)
End If
Goto Goto_Return
如果使用第二種"副程式的架構"變成連感測器都不會感測了{:soso_e101:}
Sub MAIN()
.....
.....
If Distance1 =22 Then
MyMotor.ForwardAB(400,410)
PAUSE 500
ElseIf Distance2 <22 Then
MyMotor.ForwardAB(400,430)
PAUSE 500
ElseIf Distance1 >22 Then
MyMotor.ForwardAB(430,400)
ElseIf Distance1 >50 Then
S_Name()
MyMotor.ForwardAB(430,400)
PAUSE 500
End If
Sub S_Name()
If Distance1 >50 Then
MyMotor.ForwardAB(410,0)
PAUSE 2000
MyMotor.ForwardAB(0,0)
PAUSE 500
MyMotor.ForwardAB(400,410)
PAUSE 2000
MyMotor.ForwardAB(0,0)
PAUSE 500
MyMotor.ForwardAB(410,0)
PAUSE 2000
MyMotor.ForwardAB(0,0)
End If
End Sub
老師,我們是那裡出錯嗎?
|
|