Counting Negative Numbers
Dmagee
Posts: 20
How can I make this code count negative? Once the count get to zero I want it to keep counting in the negative direction.
' {$STAMP BS2}' {$PBASIC 2.5}D_Set VAR Word ' Defalt SetpointFlag VAR Bit ' Flag that button was pressedFlag2 VAR Bit ' Flag that button was pressedMoveTo CON 2 ' Curser positionPRESSED CON 0 ' Push Button statepb1 PIN 2 ' Push Button 0nepb2 PIN 3 ' Push Button twoD_SET = 10 ' Defalt SetingDODEBUG MoveTo, 0, 1DEBUG "Defalt Setpoint... " DEBUG DEC2 (D_Set ), CRGOSUB PBLOOPPB:IF (pb2 = PRESSED) THEN ' pb2 pressedFlag2 = 1 ' Flag2 setENDIFIF (pb2 = 1) AND (Flag2 = 1) THEN ' pb not pressedD_Set = D_Set - 1 ' True -1Flag2 = 0 ' Reset Flag2ENDIFIF (pb1 = PRESSED) THEN ' pb1 pressedFlag = 1 ' Flag1 setENDIFIF (pb1 = 1) AND (Flag = 1) THEN ' pb not pressedD_Set = D_Set + 1 ' True +1Flag = 0 ' Reset Flag2ENDIFRETURN
Comments