Shop OBEX P1 Docs P2 Docs Learn Events
Number Conversion Formatters with IF-THEN statements? — Parallax Forums

Number Conversion Formatters with IF-THEN statements?

FalconFalcon Posts: 191
edited 2012-02-07 04:49 in BASIC Stamp
Hello,
I'm trying to repeat an action (V-Stamp audio Alert) between 9:00 PM and 9:03 PM if a switch is not closed using the following code

The switch is represented by "current1.bit1", and 0 is the not-closed state.

First I update the Date and Time and send it to the monitor using this:
  HIGH DS1302                           ' Select DS1302
  SHIFTOUT DataIO, Clock, LSBFIRST, [RdBurst]
  SHIFTIN DataIO, Clock, LSBPRE, [secs, mins, hrs, date, month, day, year]
  LOW DS1302                            ' Deselect DS1302

DEBUG CRSRXY, 0, 5, HEX2 month, "/", HEX2 date, "/", HEX2 year,"  ",  HEX2 hrs, ":",   HEX2 mins, ":", HEX2 secs, " "
That part works fine.

Then I tried this as an argument to go into a loop. The bit is checked within the loop so it should exit when mins >3
  IF current1.BIT1 = 0 AND hrs =  19 AND mins < 03 THEN GOTO REPEAT
That did not initiate the loop.

I also tried the HEX2 Conversion Formatter that worked with the DEBUG statements like this but it also did not work
 IF current1.BIT1 = 0 AND HEX2 hrs =  19 AND HEX2 mins < 03 THEN GOTO REPEAT

How can I write this line to GOTO REPEAT when the switch is NOT CLOSED between 9:00 PM and 9:03 PM?

falcon

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-02-06 20:53
    You can only use the formatters in the SERIN and SEROUT statements and their DEBUG equivalents. The RTC uses BCD (Binary Coded Decimal) where each digit is represented in 4 bits. You can write this using hexadecimal notation like IF hrs = $19 AND mins < $03. Remember that a time of $19 is 7pm (24 hour clock).
  • FalconFalcon Posts: 191
    edited 2012-02-07 04:49
    Thanks Mike,

    I'll try that when I get home this afternoon.

    And thanks for pointing out the 9:00 PM vs. 7:00 PM issue. Ultimately my code loop will trigger at 9:00 PM but I was trying this around 7:00 PM so that is what I used while testing. And my RTC is set to use a 24 hour clock to eliminate the AP-PM issue.

    falcon
Sign In or Register to comment.