| ROBODYSSEY SYSTEMS LLC |
|
Product Catalog Code Page Policies Gallery Whats New Press Releases Resources Links Contact Us About Us Press Educators Page BasicX and Robotics book After School Mini Challenge! Free Robots to Kids Hack-A-Toy Shopping Cart |
Page18_2
|
| PIC Home | Previous Page | Next Page | Next Chapter |

PROGRAM NAME CREATED VIA NEW PROJECT!!
COPY AND PASTE FROM NEXT LINE DOWN
'***********************************
Dim data1 as Integer
'***********************************************
Sub Procedure Forward
PortB = %00101101
end sub
'***********************************************
Sub Procedure Reverse
PortB = %00110011
end sub
'***********************************************
Sub Procedure T_Left
PortB = %00101011
end sub
'***********************************************
Sub Procedure T_Right
PortB = %00110101
end sub
'***********************************************
Sub Procedure Halt
PortB = %00000000
end sub
'***********************************************
Sub Procedure GetValA1
TrisA = %00001100 ' Set Pins on PortA to Output
data1 = 1 ' Set the data variable to 1
PortA = %00000010 ' Pulse pin 1 on PortA for 5ms
Delay_ms(5)
TrisA = %00001110 ' Get ready to suck in data
Counts:
If Testbit(PortA,1) = 1 Then 'See how long it takes to
'discharge the capacitor
data1 = data1 + 1
Goto Counts
End If
End Sub
'***********************************
Main:
TrisB = %00000000 ' Configure pins of PortB as output
TrisA = %00001100 ' Configure some pins of PortA as input(1)
CMCON = %00000111
mainloop:
GetValA1
If data1 > 128 Then
Forward
Delay_ms(1000)
Reverse
Delay_ms(1000)
T_Left
Delay_ms(3000)
T_Right
Delay_ms(3000)
Forward
Delay_ms(200)
Reverse
Delay_ms(200)
Forward
Delay_ms(200)
Reverse
Delay_ms(200)
T_Left
Delay_ms(200)
T_Right
Delay_ms(200)
End If
Halt
Goto mainloop
End.
| PIC Home | Previous Page | Next Page | Next Chapter |
| Home | Product Catalog | Shopping Cart | Resources | Links |
| Code Page | Policies | Gallery |