I am A-dawg Welcome one and all!! NOW BOW! This is my robot's site |
  |   |   | |
  |   |   | |
  |   |   | |
  |   |   |
program nobump Dim x as byte Dim Flame_Pos_Center as word Dim Flame_Pos_Right as word Dim Flame_Pos_Left as word dim Front_Edge as word dim Left_Edge as word dim Right_Edge as word dim flame as integer '************************* Sub Procedure Forward 'PortC = %10100101 'Bits 2 and 5 are Enable SetBit(PortC,0) '0 ClearBit(PortC,1) '1 SetBit(PortC,2) '2 SetBit(PortC,5) '5 ClearBit(PortC,6) '6 SetBit(PortC,7) '7 End Sub '************************* Sub Procedure Reverse PortC = %01100110 End Sub '************************* Sub Procedure T_Right PortC = %10100110 End Sub '************************* Sub Procedure T_Left PortC = %01100101 End Sub '************************* Sub Procedure Halt PortC = %00000000 End Sub '************************* Sub Procedure Sort_Flame If Flame_Pos_Right < Flame_Pos_Center then T_Right Delay_ms(200) End If If Flame_Pos_Left < Flame_Pos_Center then T_Left Delay_ms(200) End If If Flame_Pos_Center < 120 then halt x = 50 Do SetBit(PortB,0) Delay_us(600) ClearBit(PortB,0) Delay_ms(20) x = x - 1 Loop Until x = 0 x = 15 Do SetBit(PortB,0) Delay_us(1000) ClearBit(PortB,0) Delay_ms(20) x = x - 1 Loop Until x = 0 Flame_Pos_Center = 300 Flame_Pos_Right = 300 Flame_Pos_Left = 300 End If End Sub '******************** Sub Procedure Sort_Edge If left_edge < 100 then T_Right Delay_ms(200) End If If Left_edge < front_edge then T_Left Delay_ms(200) End If if front_edge < 100 then forward end if End Sub '******************** Sub Procedure Center x = 15 Do SetBit(PortB,0) Delay_us(1500) ClearBit(PortB,0) Delay_ms(20) x = x - 1 Loop Until x = 0 Flame_Pos_Center = Adc_Read(0) Front_Edge = adc_read(1) End Sub '******************** Sub Procedure FarRight x = 25 Do SetBit(PortB,0) Delay_us(2000) ClearBit(PortB,0) Delay_ms(20) x = x - 1 Loop Until x = 0 Flame_Pos_Right = Adc_Read(0) Right_Edge = adc_read(1) End Sub '******************** Sub Procedure FarLeft x = 15 Do SetBit(PortB,0) Delay_us(1000) ClearBit(PortB,0) Delay_ms(20) x = x - 1 Loop Until x = 0 Flame_Pos_Left = Adc_Read(0) Left_Edge = adc_read(1) End Sub '******************** main: trisb = %00000000 trisa = %00011111 trisc = %00000000 ADCON1 = %10000000 'sound_init(PortC,3) PortB = 0 While True '********* FarRight Center FarLeft Forward If Flame_Pos_Center < 250 Then flame = 201 Sort_Flame else flame = 199 End if If Flame_Pos_Right < 250 Then flame = 201 Sort_Flame else flame = 199 End if If Flame_Pos_Left < 250 Then flame = 201 Sort_Flame else flame = 199 End if If flame < 200 Then If Left_Edge > 450 Then t_right delay_ms(100) End if If Right_Edge > 450 Then t_left delay_ms(100) End if If Front_Edge > 450 Then t_right delay_ms(500) end if end if wend '******* 'If Front_Edge < 200 Then 'Forward 'End if End.