Define Left 0 Define Right 1 Define Forward 2 Define Back 3 Define High On Define Low Off Define True 1 Define False 0 '[ 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 ] '[LeftSw|MidSw|RightSw|LeftRF|Free_0|Right_RF|Free_1|Free_2] Define InputPort BytePort[1] Define OutputPort BytePort[2] Define FrontFreeTime 50 'InPuts Define LeftSw Port[1] Define MidSw Port[2] Define RightSw Port[3] Define LeftRF Port[4] Define Free_1 Port[5] 'unbufferd Define RightRF Port[6] Define Free_2 Port[7] 'unbufferd Define Free_3 Port[8] 'unbufferd 'Outputs Define LeftDir Port[9] Define RightDir Port[10] Define LeftMotor DA[1] Define RightMotor DA[2] Define MowMotor Port[11] Define BackLed Port[12] Define ForwardLed Port[13] Define LeftLed Port[14] Define RightLed Port[15] Define CollisionLed Port[16] Define TempB Byte Define TempW Word Define Dir Byte Define TurnDir Byte Define TurnTime Byte Define RF Byte Gosub InitUdo Dir = Forward Gosub DriveMotor Print Hour;":";Minute;":";Second TurnTime = 0 #Loop TempB = Rand TurnTime = TempB Shr 3 If Hour = 1 Then StopUdo If Second = 59 Then Gosub RandomTurn 'Change turn time after 4 Min 'If (Minute And &B00000100) Shr 2 = 1 Then TurnTime = 40 Else TurnTime = 0 If Not LeftSw Then Gosub ProcLeftSW If Not MidSw Then Gosub ProcMidSW If Not RightSw Then Gosub ProcRightSW If LeftRF Or RightRF Then Gosub MowEdge If LeftRF Then Gosub ProcLeftRF If LeftRF And RightRF Then Gosub ProcMidRF If RightRF Then Gosub ProcRightRF Goto Loop #ProcLeftRF Randomize Timer : TurnDir = Left : RF = True : Gosub CollisionProcedure Return #ProcMidRF Randomize Timer : TurnDir = Abs(Rand Mod 2) : RF = True : Gosub CollisionProcedure Return #ProcRightRF TurnDir = Right : RF = True : Gosub CollisionProcedure Return #ProcLeftSW Randomize Timer : TurnDir = Left : RF = False : Gosub CollisionProcedure Return #ProcMidSW Randomize Timer : TurnDir = Abs(Rand Mod 2) : RF = False : Gosub CollisionProcedure Return #ProcRightSW TurnDir = Right : RF = False : Gosub CollisionProcedure Return #CollisionProcedure If RF = True Then Gosub PowerDownMotor Else Gosub MotorOff Dir = Back Gosub DriveMotor Pause FrontFreeTime Gosub PowerDownMotor Dir = TurnDir Gosub DriveMotor Pause TurnTime Gosub PowerDownMotor Pause 25 Dir = Forward Gosub DriveMotor Return #RandomTurn Gosub PowerDownMotor Randomize Timer Dir = Abs(Rand Mod 2) 'Random' Gosub DriveMotor Pause TurnTime Gosub PowerDownMotor Pause 25 Dir = Forward Gosub DriveMotor Return #DriveMotor LeftLed = High : RightLed = High : ForwardLed = High : BackLed = High On Dir Gosub SetDriveLeft,SetDriveRight,SetDriveForward,SetDriveBack Gosub PowerUpMotor Return #InitUdo MowMotor = Off Gosub MotorOff Year = 0:Month = 0:Day = 0:Hour = 0:Minute = 0:Second = 0 For TempB = 1 to 10 BackLed=Low:Pause 10 : BackLed=High ForwardLed=Low:Pause 10 : ForwardLed=High LeftLed=Low:Pause 10 : LeftLed=High RightLed=Low:Pause 10 : RightLed=High Next TempB Return #StopUdo Print "UDO Stopped at ";Hour;":";Minute;":";Second MowMotor = Off Gosub PowerDownMotor LeftLed=High:RightLed=High:ForwardLed=High #EndLess Goto EndLess 'End #SetDriveLeft Print "Left" LeftLed=Low LeftDir=On:RightDir=Off:LeftMotor=Off:RightMotor=Off Return #SetDriveRight Print "Right" RightLed=Low LeftDir=Off:RightDir=On:LeftMotor=Off:RightMotor=Off Return #SetDriveForward Print "Forward" ForwardLed=Low LeftDir=On:RightDir=On:LeftMotor=Off:RightMotor=Off Return #SetDriveBack Print "Back" BackLed=Low LeftDir=Off:RightDir=Off:LeftMotor=Off:RightMotor=Off Return #MotorOff LeftMotor=Off:RightMotor=Off Return #PowerUpMotor For TempB = 100 To 254 LeftMotor=TempB:RightMotor=TempB Next LeftMotor=255:RightMotor=255 Return #PowerDownMotor For TempB = 0 To 155 LeftMotor=255-TempB:RightMotor=255-TempB Next LeftMotor=0:RightMotor=0 Return