Shop OBEX P1 Docs P2 Docs Learn Events
0 to 60 counter — Parallax Forums

0 to 60 counter

axial28rraxial28rr Posts: 16
edited 2011-05-04 19:39 in BASIC Stamp
hey guys

i need to make a 60 second countdown timer with 2 push buttons 1 push button need to set a number in the TENS coulum and sets that number value .

the second pushbutton needs to set a number in the ONES colum then sets that number value

then when both push buttons are pushed it counts down to "0"

this is what i have so far

what am having prblems with is that when i push a button its shows all 9 numbers (0 -9)insted of 1 number

ex i push the push button 6 times i shoud see 0 to 5 on the debug and its sets that number

thanks
' What's a Microcontroller - SegmentTestWithHighLow.bs2
' Individually test each segment in a 7-Segment LED display.
'{$STAMP BS2}
'{$PBASIC 2.5}
 
startval VAR Nib
ENDval VAR Nib
x VAR Nib
y VAR Nib

main:
  FOR y = startval TO endval
  DEBUG DEC x ,CR
  IF IN3 = 1 AND IN4 = 0 THEN
  startval = 0
  endval = 9
  LOOKDOWN x, [1,2,3,4,5,6,7,8,9],x
  LOOKUP y, [%10111110, %00010010, %01111100,
                   %01110110, %11010010, %11100110,
                   %11001110, %00110010, %11111110,
                   %11110010], y
ENDIF
NEXT
  FOR y = startval TO endval
  GOSUB main
  DEBUG DEC x ,CR
  IF IN3 = 0 AND IN4 = 1 THEN
  startval = 0
  endval = 9
  LOOKDOWN x, [1,2,3,4,5,6,7,8,9],x
  LOOKUP y, [%10111110, %00010010, %01111100,
                   %01110110, %11010010, %11100110,
                   %11001110, %00110010, %11111110,
                   %11110010], y
              DIRH = %11111111
ENDIF
NEXT
 

Comments

  • vaclav_salvaclav_sal Posts: 451
    edited 2011-05-04 17:37
    As presented , your code won't even compile - the variable "counter" is undefined.
    And there are other logical and syntax errors.
    You need to compile it first before troubleshooting these errors.

    Is this a direct copy from the text you are quoting ?
    Can you copy and post the code from the text you are using?
  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-04 18:43
    Even if it would compile, it wouldn't run for long. You've got a recursive GOSUB main call and no RETURN anywhere.
  • axial28rraxial28rr Posts: 16
    edited 2011-05-04 19:39
    sorry wrong code i put the new one in that on complies but i cant test if it runs because i do not have a micro c
Sign In or Register to comment.