| CODE |
| ' ' Function to pulse LED outputs and detect stuff ' ' Toggles left and right LED 10 cycles of 26us + 260us delay between ' for a total run time of 800us. ' ' Initialize Portb bits 5 & 6 as outputs, set high and ' portb bit 7 as input with pull-up enabled (1) ' ' to use, declare function at top of program, then call, assigning ' the return value to a variable for analysis. ' ' Returns 0,1,2 or 3 indicating nothing, left, right or both. ' Function Doproximity() As Byte Local I As Byte Doproximity = 0 For I = 1 To 20 Toggle Portb.6 Waitus 7 Next I If Pinb.7 = 0 Then Doproximity = 1 Waitus 255 For I = 1 To 20 Toggle Portb.5 Waitus 7 Next I If Pinb.7 = 0 Then Doproximity = Doproximity + 2 End Function |