well, because
1)PBP don't have PRINT but LCDOUT,
2)PBP don't allow to use LOW as Variable, should be the same with PDS
3)PBP don't use DEC to decrement a variable, not sure in PDS
4)PBP don't use INC to increment a variable, not sure in PDS
5)There's no DelayMS in PBP but PAUSE
6)REVERSE is a reserved word in PBP
Now if you use PDS, we can't really help, www.picbasic.org/forum will.
you may try this one...
HTHCode:WHILE 1 = 1 'Infinite loop IF S1 = 0 THEN IF SPEED = 0 THEN DIRECTION = REVERSE 'If motor stopped, set reverse direction IF DIRECTION = REVERSE THEN 'If engine in reverse, then.. IF SPEED < 255 THEN SPEEED= SPEED +1 'If Speed less than Maximum, then increase ENDIF ELSE 'Else goto FORWARD loop IF SPEED > 0 THEN SPEED = SPEED -1 'If speed not yet 0, then decrease speed ENDIF ENDIF ENDIF IF S2 = 0 THEN 'If S2 pressed, then IF SPEED = 0 THEN DIRECTION = FORWARD 'If motor stopped, set forward direction IF DIRECTION = FORWARD THEN 'If engine in reverse, then.. IF SPEED < 255 THEN SPEED=SPEED+1 'If speed not yet 255, then increase speed ENDIF ELSE 'Else goto REVERSE loop) IF SPEED > 0 THEN SPEED= SPEED-1 'If speed not yet 0, then reduce until 0 ENDIF ENDIF ENDIF FORWARD = DIRECTION 'As DIRECTION = HIGH then 'FORWARD = HIGH REVERSE = ~FORWARD 'REVERSE is negated to FORWARD HPWM 1, SPEED, 2000 'Alloctae 'SPEED' value to the CCP module PRINT AT 1, 13, DEC (SPEED * 100) / 255, "% " 'Reflect speed in % DELAYMS 10 'Increase SPEED IF SPEED = 0 THEN DELAYMS 700 'Wait longer when speed =0 endif WEND 'To While




Bookmarks