By what you provide, it will look like almost thisbe sure of the way you interpret your sensor... i'm not sure about the info you provide.Code:TRISB=%00001111 LM_FWD var PORTB.4 LM_REV var PORTB.5 RM_FWD var PORTB.6 RM_REV var PORTB.7 MaskPORTB var byte PeriodHALF var word ' Variable for Half Speed period (pulsout) PeriodMIN var word ' Variable for Min Speed period (pulsout) ' You'll have to determine value for PeriodMIN & PeriodHALF here PORTB=0 Start: MaskPORTB=(PORTB>>1) & $07 ' get only B1,B2,B3 value Select case maskportb 'LS(0) CS(1) RS (0) LM_FWD(FULL SPEED) RM_FWD (FULL) case 2 LM_FWD =1 RM_FWD =1 'LS(1) CS(1) RS (0) LM_FWD(HALF SPEED) RM_FWD (FULL) case 3 pulsout LM_FWD, PeriodHALF RM_FWD=1 'LS(0) CS(1) RS (1) LM_FWD(HALF) RM_FWD (MAX) case 6 pulsout LM_FWD, PeriodHALF RM_FWD=1 'LS(0) CS(0) RS (1) LM_FWD(MAX SPEED) RM_FWD (MIN) case 4 LM_FWD = 1 pulsout RM_FWD,PeriodMIN end select goto start
you mean ?2. another things is how to control
if the 3 Sensor = 1 3 times cross 4 junction, the robot will stop and turn 90 deg left (for example)




Bookmarks