(NEED HELP) I need the code for a digital clock using just the DEBUG TERMINAL SCREEN
evan79491
Posts: 9
in BASIC Stamp
Using no components just the basic stamp and computer.
Design code to display time onto the terminal screen.
Need to be able to set anytime and have it go through the cycle.
@xanadu
Design code to display time onto the terminal screen.
Need to be able to set anytime and have it go through the cycle.
@xanadu
Comments
Can you post the code you have so far?
So i have pretty much not really gotten far at all i just dont know what i am supposed to use.
I have this right now but this is like the 5th thing i have started lol i just really need help in general
' {$STAMP BS2}
' {$PBASIC 2.5}
secs VAR Byte '
mins VAR Byte '
hrs VAR Byte '
startVal VAR Byte
endVal VAR Byte
Setup:
startVal = 1
endVal = 60
mins =1
Main:
FOR secs = startVal TO endVal
PAUSE 1000
DEBUG CRSRXY, 100, 12, DEC secs, CR
DEBUG CRSRXY, 98, 12, DEC mins, CR
IF (secs = 60) THEN
startVal = 1
endVal = 60
DEBUG CRSRXY, 98, 12, DEC mins +1, CR
ENDIF
NEXT
End this line of code like the lines above it, increment your mins var on the next line. Then you can add hours after it.
Here is a simple example using IF/THEN. There are cleaner ways to do this, but this is the easiest to
understand IMO. Now you can apply the same thing to what you have. -
I start a loop for seconds, and then pause for just under a second to compensate for the rest my code. When the seconds equal 60, minutes go up, and then seconds are reset. When minutes are 60 hours go up and minutes are reset. When hours hit 13 we reset them to 1. When it's 11 hours and 59 minutes and 59 seconds we can toggle AM/PM status.
When you output to the terminal you don't need the ",CR" (carriage return) at the end when using CRSRXY. I would setup the display first, this would only run once:
Then I would run the timing loop and update the display like this. You will notice DEC2 that will format the number as two digits, 2 = 02, which makes it feel more like a clock to me.
http://www.parallax.com/go/PBASICHelp/Content/LanguageTopics/Commands/SERIN.htm
Toward the bottom you will see usage examples.
http://forums.parallax.com/discussion/77867/ds1302-demo-code-updated