How to make a word as decimal in if then else statement


Results 1 to 17 of 17

Threaded View

  1. #10
    Join Date
    Jan 2011
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    I will explain what I am trying to do... maybe it helps... in bad english, lol

    I've got 2 components, a DS1820 and a simple LED, both on other ports.
    When the DS1820 gets on 21,2celcius for example, the LED must blink, on 21,2+ the LED stays on, on 21,2- the LED turns off. The code I've got to control the DS1820 is:

    Code:
    Above clear:
    SYMBOL Convert      = $44 
    SYMBOL RdScratchPad = $BE
    SYMBOL SkipROM      = $CC
    SYMBOL Graad        = 223    
    SYMBOL DS1820       = PORTA.1
    SYMBOL verwarming   = PORTA.6
    
    DIM Temp            AS WORD
    DIM Remain          AS BYTE
    DIM Slope           AS BYTE
    DIM BD1             AS BYTE   
    
    --------
    
      OWRITE DS1820, 1, [SkipROM, Convert]
      OWRITE DS1820, 1, [SkipROM, RdScratchPad]
      OREAD  DS1820, 2, [Temp.LOWBYTE, Temp.HIGHBYTE, BD1, BD1, BD1, BD1, Remain, Slope] ',CRC]
     
      Temp = (((Temp >> 1) * 100) - 25) + (((Slope - Remain) * 100) / Slope)                
                                                                    
      PRINT AT 1, 1, DEC Temp / 100, ".", DEC1 Temp / 10, Graad, "C  "
    [edit]
    by the way, verwarming is dutch... but doens't mather... it's just a symbol
    [/edit]
    But how can i control the LED with the code above? I used a IF then ELSE statement on Temp but Temp shows only symbols (not with DEC in front of it at the PRINT line, so not on LCD with that code)

    [edit2]
    When i use this, just for example what Temp do without DEC, I get the most funnyest symbols and icons on LCD
    Code:
      PRINT AT 1, 1, Temp
    Anyhow... I need to put it in a If then Else statement... to control the led
    [/edit2]
    Last edited by jeroeni; - 24th January 2011 at 15:36.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts