DS18b20 termermometre için RGB Led ışık.

Başlatan MC_Skywalker, 31 Mayıs 2009, 19:36:54

MC_Skywalker

Merhaba;

uzunca bir süre arma vermiş olduğum pic merakıma aklıma gelen bir fikir ile geri döndüm.

DS18B20 ve 16F62A ile bit termometre yapıp  buna bir RGB led eklemeye karar verdim. forum içinde DS18B20 okuma ile ilgili örenekleri alıp inceleyip işe koyulmaya başladım.

öncelikle LCD eklemden düşündüğüm kodun çalışıp çalışıpmaycağını deneme amaçlı ağaıdaki kodları yazmya başladım. fakat işin içinde çıkamadım. yazdığım kodda bir matık ve söz dizim hatası var sanırım ama ben bir türlü bunu fark edemedim sizlerin yardımlarını bekliyorum.

@ DEVICE pic16F628 'islemci 16F628A
@ DEVICE pic16F628, WDT_OFF 'Watch Dog timer kapali
@ DEVICE pic16F628, PWRT_ON 'Power on timer acik
@ DEVICE pic16F628, PROTECT_OFF 'Kod koruma kapali
@ DEVICE pic16F628, MCLR_ON 'MCLR pini kullaniliyor.
@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT  'Dahili osilatör kullanilacak
@ DEVICE pic16F628, LVP_OFF
@ DEVICE pic16F628, BOD_OFF



DEFINE Rled PortB.0
DEFINE Gled PortB.1
DEFINE Bled PortB.2

CMCON=7                      'CCP iptal hepsi giriş çıkış
OPTION_REG.7=0               'pull-up dirençleri aktif
TrisA=%0000001 
TrisB=0 
PortA=0 
PortB=0

io_Pin    VAR PortA.0
Bussy       VAR BIT
HAM         VAR WORD
ISI         VAR WORD


TEMP        VAR BYTE
Float       VAR WORD

tR          VAR BYTE
tG          VAR BYTE
tB          VAR BYTE

a           VAR BYTE
i            VAR BYTE

basla:
gosub sensor
Gosub sov 
;*******************************************************************************
sensor:

           OWOUT   io_Pin, 1, [$CC, $44]
Bekle:
           OWIN    io_Pin, 4, [Busy]   
           IF      Busy = 0 THEN Bekle 
           OWOUT   io_Pin, 1, [$CC, $BE]
           OWIN    io_Pin, 2, [HAM.Lowbyte, HAM.Highbyte]
           GOSUB   Hesapla
           RETURN
   
Hesapla:             

        TEMP = 625 * (HAM+1)       
        ISI = DIV32 10         
        FLOAT = (ISI //1000)/100
        ISI=ISI/1000
        RETURN
 ;******************************************************************************
sov:
        if ISI < 20 then (tR = 255, tG = 0, tB = 255)
        if ISI >= 20 && ISI < 21 then (tR = 255, tG = 0, tB = 255)
        if ISI >= 21 && ISI < 22 then (tR = 204, tG = 0, tB = 255)        
        
        for a = 0 to 25
        for i = 0 to 255
        
        if i <= tR  THEN  Rled = 1
        if i > tR then Rled = 0
        
        if i <= tG  THEN  Gled = 1
        if i > tG then Gled = 0
        
        if i <= tB  THEN  Bled = 1
        if i > tB then Bled = 0
        
        next i
        next a
        pauseus 20
        return
        


yapmaya çalıştığım belirli bir ısı değerinde RGB ledin yanışını ayarlamak.

mustafa_cmbz

sorun renk oluşumu ise yazılımsal pwm komutunu kullanmanı tavsiye ederim...

ftsahin

Kod üzerinde değişiklik yapmak zorunda kaldım çünkü hata veriyordu. Bu haliyle proteusta çalışıyor gerçekte denemedim. RGB bölümünün çalıştığını test etmek için devreyi kurmanız gerek Proteus gerçek zamanlı RGB gösteremiyor.

'@ DEVICE pic16F628a 'islemci 16F628A 
'@ DEVICE pic16F628, WDT_OFF 'Watch Dog timer kapali 
'@ DEVICE pic16F628, PWRT_ON 'Power on timer acik 
'@ DEVICE pic16F628, PROTECT_OFF 'Kod koruma kapali 
'@ DEVICE pic16F628, MCLR_ON 'MCLR pini kullaniliyor. 
'@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT  'Dahili osilatör kullanilacak 
'@ DEVICE pic16F628, LVP_OFF 
'@ DEVICE pic16F628, BOD_OFF 

Device=16F628A
XTAL=4


Symbol Rled PORTB.0 
Symbol Gled PORTB.1 
Symbol Bled PORTB.2 
Symbol io_Pin PORTA.0 

CMCON=7                      'CCP iptal hepsi giriş çıkış 
OPTION_REG.7=0               'pull-up dirençleri aktif 
TRISA=%0000001 
TRISB=0 
PORTA=0 
PORTB=0 



Busy   VAR Bit 
HAM    VAR Word 
ISI    VAR Word 


TEMP   VAR Byte 
Flot   VAR Word 

tR    VAR Byte 
tG    VAR Byte 
tB    VAR Byte 

a     VAR Byte 
i     VAR Byte 
j     var Byte

basla: 

       OWrite   io_Pin, 1, [$CC, $44] 
     Bekle: 
       ORead    io_Pin, 4, [Busy]    
       If      Busy = 0 Then Bekle 
       OWrite   io_Pin, 1, [$CC, $BE] 
       ORead    io_Pin, 2, [HAM.LowByte, HAM.HighByte] 
         
       TEMP = 625 * (HAM+1)        
       ISI = Div32 10          
       Flot = (ISI //1000)/100 
       ISI=ISI/1000 
         
       For j=1 To 50   
          If ISI < 20 Then 
            tR = 20
            tG = 100
            tB = 200
          EndIf   
          If ISI = 20 Then
            tR = 100
            tG = 150
            tB = 100
          EndIf   
          If ISI > 20 Then 
            tR = 200
            tG = 50
            tB = 20
          EndIf         
          For a = 0 To 25 
            For i = 0 To 255 

              If i <= tR  Then  Rled = 1 
              If i > tR Then Rled = 0 
        
              If i <= tG  Then  Gled = 1 
              If i > tG Then Gled = 0 
        
              If i <= tB  Then  Bled = 1 
              If i > tB Then Bled = 0 
        
             Next i 
           Next a 
         Next j  
GoTo basla

MC_Skywalker

@mustafa_cmbz

evet bende PWM düşündüm ama  bir tablo oluşturduğumda onun iş zamanı ve duty zamnı çevrimini nasıl yacağımı bulamadım.

       if ISI < 20 then (tR = 255, tG = 0, tB = 255)
        if ISI >= 20 && ISI < 21 then (tR = 255, tG = 0, tB = 255) // pembe
        if ISI >= 21 && ISI < 22 then (tR = 204, tG = 0, tB = 255)
        if ISI >= 22 && ISI < 23 then (tR = 153, tG = 0, tB = 255)
        if ISI >= 23 && ISI < 24 then (tR = 102, tG = 0, tB = 255)
        if ISI >= 24 && ISI < 25 then (tR = 51, tG = 0, tB = 255)
        if ISI >= 25 && ISI < 26 then (tR = 0, tG = 0, tB = 255)     // mavi
        if ISI >= 26 && ISI < 27 then (tR = 0, tG = 51, tB = 255)
        if ISI >= 27 && ISI < 28 then (tR = 0, tG = 102, tB = 255)
        if ISI >= 28 && ISI < 29 then (tR = 0, tG = 153, tB = 255)
        if ISI >= 29 && ISI < 30 then (tR = 0, tG = 204, tB = 255)
        if ISI >= 30 && ISI < 31 then (tR = 0, tG = 255, tB = 255) //turkuaz
        if ISI >= 31 && ISI < 32 then (tR = 0, tG = 255, tB = 204)
        if ISI >= 32 && ISI < 33 then (tR = 0, tG = 255, tB = 153)
        if ISI >= 33 && ISI < 34 then (tR = 0, tG = 255, tB = 102)
        if ISI >= 35 && ISI < 36 then (tR = 0, tG = 255, tB = 0)     //yaeşil


@ftsahin

yardımların teşekür ederim. bu akşa derleyip deneyeceğim.

MC_Skywalker

@ftsahin  verdiğin kodalrı pbp 2.50 de derleyemedim.


kendi kodumu biraz geliştirdim fakat bufferoverflow hatası veriyor poreteusta

@ DEVICE pic16F628A 'islemci 16F628A
@ DEVICE pic16F628A, WDT_OFF 'Watch Dog timer kapali
@ DEVICE pic16F628A, PWRT_ON 'Power on timer acik
@ DEVICE pic16F628A, PROTECT_OFF 'Kod koruma kapali
@ DEVICE pic16F628A, MCLR_ON 'MCLR pini kullaniliyor.
@ DEVICE pic16F628A, INTRC_OSC_NOCLKOUT  'Dahili osilatör kullanilacak
@ DEVICE pic16F628A, LVP_OFF
@ DEVICE pic16F628A, BOD_OFF


'DEFINE R_led PortB.0
'DEFINE G_led PortB.1
'DEFINE B_led PortB.2

CMCON=7                      'CCP iptal hepsi giriş çıkış
OPTION_REG.7=0               'pull-up dirençleri aktif
TrisA=%0000001
TrisB=0
PortA=0
PortB=0

io_Pin      VAR PortA.0
Busy       VAR BIT
HAM         VAR WORD
ISI         VAR WORD


TEMP        VAR BYTE
Float       VAR WORD

tR          VAR BYTE
tG          VAR BYTE
tB          VAR BYTE

a           VAR BYTE
i           VAR BYTE

basla:
gosub sensor
Gosub sov
;*******************************************************************************
sensor:

           OWOUT   io_Pin, 1, [$CC, $44]
Bekle:
           OWIN    io_Pin, 4, [Busy]   
           IF      Busy = 0 THEN Bekle
           OWOUT   io_Pin, 1, [$CC, $BE]
           OWIN    io_Pin, 2, [HAM.Lowbyte, HAM.Highbyte]
           GOSUB   Hesapla
           RETURN
   
Hesapla:             

        TEMP = 625 * (HAM+1)       
        ISI = DIV32 10         
        FLOAT = (ISI //1000)/100
        ISI=ISI/1000
        RETURN
 ;******************************************************************************
sov:
        if ISI < 20 then 
         tR = 255
         tG = 0
         tB = 255
        ENDIF 
        if ISI >= 20 && ISI < 21 then       
         tR = 255 
         tG = 0 
         tB = 255
        endif         
        if ISI >= 21 && ISI < 22 then
         tR = 204
         tG = 0
         tB = 255
        ENDIF
        if ISI >= 22 && ISI < 23 then
         tR = 153
         tG = 0
         tB = 255
        ENDIF 
        if ISI >= 23 && ISI < 24 then
         tR = 102
         tG = 0
         tB = 255
        ENDIF 
        if ISI >= 24 && ISI < 25 then
         tR = 51 
         tG = 0 
         tB = 255
        ENDIF 
        if ISI >= 25 && ISI < 26 then
         tR = 0 
         tG = 0 
         tB = 255                           'mavi
        ENDIF 
        if ISI >= 26 && ISI < 27 then
         tR = 0 
         tG = 51 
         tB = 255
        ENDIF 
        if ISI >= 27 && ISI < 28 then
         tR = 0 
         tG = 102 
         tB = 255
        ENDIF 
        if ISI >= 28 && ISI < 29 then
         tR = 0 
         tG = 153 
         tB = 255
        ENDIF 
        if ISI >= 29 && ISI < 30 then
         tR = 0 
         tG = 204 
         tB = 255
        ENDIF 
        if ISI >= 30 && ISI < 31 then
         tR = 0
         tG = 255
         tB = 255                           'turkuaz
        ENDIF 
        if ISI >= 31 && ISI < 32 then
         tR = 0
         tG = 255 
         tB = 204
        ENDIF 
        if ISI >= 32 && ISI < 33 then
         tR = 0
         tG = 255 
         tB = 153
        ENDIF 
        if ISI >= 33 && ISI < 34 then
         tR = 0 
         tG = 255 
         tB = 102
        ENDIF 
        if ISI >= 35 && ISI < 36 then
         tR = 0
         tG = 255
         tB = 0                             'yeşil 
        ENDIF 
        
        for a = 0 to 25
            for i = 0 to 255
       
            if i <= tR  THEN  PortB.0 = 1
            'ENDIF 
            if i > tR then  PortB.0 = 0            
           ' endif
            if i <= tG  THEN PortB.1 = 1            
          '  ENDIF 
            if i > tG then PortB.1 = 0  
           ' endif
            if i <= tB  THEN PortB.2 = 1  
           ' ENDIF 
            if i > tB then  PortB.2 = 0  
            'ENDIF
            next i
        next a
        pauseus 20
RETURN


buda derlendikten sonraki hex dosyası

:10000000C228083033190130A300A2013608840049
:100010003408452034088004C1200E2884130005CC
:10002000FF3E331DA20C3319A20D32304B20A30B1F
:10003000082822080314BD28A20008303319013013
:10004000A300A20C360884003408452034080318A5
:10005000800437304B2034088004A30B212803147C
:10006000BD28B31CBD283728B300331CBD28360873
:100070008400340845200130A100E0304C203408D1
:1000800080040130A100E0304C28FF3A8005482868
:1000900084178005BD28A101E83EA000A109FC301D
:1000A000031C5528A00703185228A0076400A10FBD
:1000B000522820185B28A01C5F2800005F28080039
:1000C000A20003306628A20004306628A800230896
:1000D0002102031D6D28220820020430031801307C
:1000E000031902302805031DFF30BD280038031D09
:1000F000FF300405031DFF30BD28A2002008A60024
:100100002408A0002608A4002108A6002508A100B4
:100110002608A5008D28A501A4011030A600210DF8
:10012000A40DA50D2208A4022308031C230FA50279
:100130000318A1282208A40723080318230FA507E2
:100140000310A00DA10DA60B8F282008BD2810308C
:10015000A800A101A001A70CA60C031CB528220829
:10016000A00723080318230FA107A10CA00CA50CBE
:10017000A40CA80BAB282408BD28831303138312F7
:100180006400080007309F0083168113013085004A
:100190008601831285018601CE203D210530B600FF
:1001A0000130B40001303420CC301C2044301C20FD
:1001B00031200530B6000130B40004303420012075
:1001C000013903194410031D441431206400441CF8
:1001D000D9280530B6000130B40001303420CC30CD
:1001E0001C20BE301C2031200530B6000130B40088
:1001F000023034200120BA000120BB00312001214F
:10020000080001303A07BE003B080318013EBF005A
:100210007130A6000230A7003E08A2003F08A300EC
:10022000A720C600A3010A307D20BC002108BD0024
:100230003C08A0003D08A100E830A2000330A30064
:100240008B202408BE002508BF003E08A0003F0800
:10025000A1006430A200A3018B20B8002108B900DE
:100260003C08A0003D08A100E830A2000330A30034
:100270008B20BC002108BD0008003C08A0003D0800
:10028000A100A30114306020031D4B29FF30C800DA
:10029000C701FF30C5003C08A0003D08A100A30134
:1002A00014306020BE003C08A0003D08A100A3015E
:1002B00015306320C0003E08840040087620C0004E
:1002C000C10064004008410403196B29FF30C800D5
:1002D000C701FF30C5003C08A0003D08A100A301F4
:1002E00015306020BE003C08A0003D08A100A3011D
:1002F00016306320C0003E08840040087620C0000D
:10030000C10064004008410403198B29CC30C800A7
:10031000C701FF30C5003C08A0003D08A100A301B3
:1003200016306020BE003C08A0003D08A100A301DB
:1003300017306320C0003E08840040087620C000CB
:10034000C1006400400841040319AB299930C8007A
:10035000C701FF30C5003C08A0003D08A100A30173
:1003600017306020BE003C08A0003D08A100A3019A
:1003700018306320C0003E08840040087620C0008A
:10038000C1006400400841040319CB296630C8004D
:10039000C701FF30C5003C08A0003D08A100A30133
:1003A00018306020BE003C08A0003D08A100A30159
:1003B00019306320C0003E08840040087620C00049
:1003C000C1006400400841040319EB293330C80020
:1003D000C701FF30C5003C08A0003D08A100A301F3
:1003E00019306020BE003C08A0003D08A100A30118
:1003F0001A306320C0003E08840040087620C00008
:10040000C10064004008410403190A2AC801C70159
:10041000FF30C5003C08A0003D08A100A3011A3030
:100420006020BE003C08A0003D08A100A3011B30D5
:100430006320C0003E08840040087620C000C10050
:1004400064004008410403192A2AC8013330C70058
:10045000FF30C5003C08A0003D08A100A3011B30EF
:100460006020BE003C08A0003D08A100A3011C3094
:100470006320C0003E08840040087620C000C10010
:1004800064004008410403194A2AC8016630C700C5
:10049000FF30C5003C08A0003D08A100A3011C30AE
:1004A0006020BE003C08A0003D08A100A3011D3053
:1004B0006320C0003E08840040087620C000C100D0
:1004C00064004008410403196A2AC8019930C70032
:1004D000FF30C5003C08A0003D08A100A3011D306D
:1004E0006020BE003C08A0003D08A100A3011E3012
:1004F0006320C0003E08840040087620C000C10090
:1005000064004008410403198A2AC801CC30C7009E
:10051000FF30C5003C08A0003D08A100A3011E302B
:100520006020BE003C08A0003D08A100A3011F30D0
:100530006320C0003E08840040087620C000C1004F
:100540006400400841040319AA2AC801FF30C7000B
:10055000FF30C5003C08A0003D08A100A3011F30EA
:100560006020BE003C08A0003D08A100A30120308F
:100570006320C0003E08840040087620C000C1000F
:100580006400400841040319CA2AC801FF30C700AB
:10059000CC30C5003C08A0003D08A100A3012030DC
:1005A0006020BE003C08A0003D08A100A30121304E
:1005B0006320C0003E08840040087620C000C100CF
:1005C0006400400841040319EA2AC801FF30C7004B
:1005D0009930C5003C08A0003D08A100A3012130CE
:1005E0006020BE003C08A0003D08A100A30122300D
:1005F0006320C0003E08840040087620C000C1008F
:1006000064004008410403190A2BC801FF30C700E9
:100610006630C5003C08A0003D08A100A3012330BE
:100620006020BE003C08A0003D08A100A3012430CA
:100630006320C0003E08840040087620C000C1004E
:100640006400400841040319292BC801FF30C7008A
:10065000C501C20164001A3042020318582BC301BD
:10066000640043084802031C362B06146400430848
:10067000480203183C2B0610640043084702031C81
:10068000422B86146400430847020318482B861047
:10069000640043084502031C4E2B06156400430802
:1006A00045020318542B0611C30F302BC20F2A2BFF
:0606B00014304B2008008D
:02400E00303F41
:00000001FF

ftsahin

Alıntı yapılan: "MC_Skywalker"@ftsahin  verdiğin kodalrı pbp 2.50 de derleyemedim.



Protona göre düzenleme yapmıştım ondandır. Derlenmiş hali aşağıda.

:10000000A728A500083022190130A600A50C200859
:1000100084002108FF3A8005841780052108031811
:1000200080043C304C2021088004A60B06280314D1
:10003000A228083022190130A600A501200884005A
:100040002108FF3A80058417800521088004841365
:100050000005FF3E221DA50C2219A50D32304C20B3
:10006000A60B202825080314A228A21CA2283B289E
:10007000A200221CA228200884002108FF3A800543
:10008000841780050130A400F4304D20210880043D
:100090000130A400F4304D28A401E83EA300A409D7
:1000A000FC30031C5628A30703185328A30700009D
:1000B000A40F532823185C28A31C60280000602884
:1000C0000800A601A5002308A9002708A300290805
:1000D000A7002408A9002808A4002908A80072285D
:1000E000A801A7011030A900240DA70DA80D25080F
:1000F000A7022608031C260FA80203188628250835
:10010000A70726080318260FA8070310A30DA40DA0
:10011000A90B74282308A2281030AB00A401A30166
:10012000AA0CA90C031C9A282508A3072608031863
:10013000260FA407A40CA30CA80CA70CAB0B9028AB
:100140002708A22883138312031300000800073036
:100150009F0083168113013085008601831285017B
:1001600086010530A0000130A1000130A200382036
:10017000CC300120443001200530A0000130A10026
:100180000430A2001920013903192E10031D2E146A
:100190002E18CB28BC280530A0000130A10001306A
:1001A000A2003820CC300120BE3001200530A00054
:1001B0000130A1000230A2001920AF001920B000C8
:1001C000352001302F07AC0030080318013EAD0088
:1001D000AA012C08A9000230A6007130A5008C20CD
:1001E000B3000A306120B1002408B2003208A40034
:1001F0003108A3000330A600E830A50070202808CD
:10020000AD002708AC002D08A4002C08A300A6010F
:100210006430A5007020B4002408B5003208A400A2
:100220003108A3000330A600E830A5007020B1001B
:100230002408B2000130BB0033303B02031872299E
:10024000B208031D2D291430310203182D29143052
:10025000B6006430B700C830B8003108143A320430
:10026000031D38296430B6009630B7006430B800FA
:10027000B208031D3F2915303102031C4529C8303F
:10028000B6003230B7001430B800B9011A30390264
:1002900003186F29BA013A083602031C50290614C4
:1002A0003A0836020318552906103A083702031C8B
:1002B0005A2986143A08370203185F2986103A082B
:1002C0003802031C642906153A0838020318692904
:1002D0000611BA0A031D4B29B90A031D4629BB0A98
:0602E000031D1C29B128DA
:02400E00223F4F
:00000001FF

MC_Skywalker

@ftsahin

hex için sağol.

şu buffer overflow olayını bir çözsem bulamadım bir türlü. çözeresem LCD de ekleyeceğim. RGB ledi LCD nin arka ışığı yerine kullanmayı düşünüyorum

MC_Skywalker

projemin son hali aşağıdaki gibi. proteusta denedim pronlem göremedim. 16f628A elimde yoktu gerçek anlamda denemyemedim hafta sonu alabilirsem deneyeceğim

'****************************************************************
'*  Name    : LCDveRGB.PBP                                      *
'*  Author  : MC_Skywlaker                                      *
'*  Notice  : Copyright (c) 2009 MC_Skywalker                   *
'*          : All Rights Reserved                               *
'*  Date    : 02.06.2009                                        *
'*  Version : 1.0                                               *
'*  Notes   : DS18B20 ile LCD ve RGB led kulanılarak yapılmış   *
'*          : termometre                                        *
'****************************************************************
@ DEVICE pic16F628A 'islemci 16F628A
@ DEVICE pic16F628A, WDT_OFF 'Watch Dog timer kapali
@ DEVICE pic16F628A, PWRT_ON 'Power on timer acik
@ DEVICE pic16F628A, PROTECT_OFF 'Kod koruma kapali
@ DEVICE pic16F628A, MCLR_ON 'MCLR pini kullaniliyor.
@ DEVICE pic16F628A, INTRC_OSC_NOCLKOUT  'Dahili osilatör kullanilacak
@ DEVICE pic16F628A, LVP_OFF
@ DEVICE pic16F628A, BOD_OFF

'***********LCD Tanımlamaları*************************************************** 
DEFINE LCD_DREG     PORTB 
DEFINE LCD_DBIT         4 
DEFINE LCD_EREG     PORTB 
DEFINE LCD_EBIT         1 
DEFINE LCD_RWREG    PORTB 
DEFINE LCD_RWBIT        2 
DEFINE LCD_RSREG    PORTB 
DEFINE LCD_RSBIT        3 
DEFINE LCD_BITS         4 
DEFINE LCD_LINES        2        
'***********Özel Karakter Tanımlamaları***************************************** 
LCDOUT $FE,$40, 6, 9, 9, 6, 0, 0, 0, 0 'Derece İşareti 
'***********Port Ayarları******************************************************* 

CMCON=7                      'CCP iptal hepsi giriş çıkış
OPTION_REG.7=0               'pull-up dirençleri aktif
TrisA=%0000001
TrisB=0
PortA=0
PortB=0

io_Pin       VAR PortA.0
Busy         VAR BIT
HAM          VAR WORD
ISI          VAR WORD
TEMP         VAR BYTE
Float        VAR WORD
SIGN         VAR BYTE 
SIGN_BITI    VAR HAM.Bit11
NEGAT_ISI    CON 1 
tR           VAR BYTE
tG           VAR BYTE
tB           VAR BYTE

a            VAR BYTE
i            VAR BYTE

'***********LCD yi Kullanıma Hazır Hale Getir***********************************
PAUSE 500 
LOW PORTB.2 'RW bacağı ekrana yazmaya imkan vermek için LOW yapıldı. 
lcdout $FE,1 
PAUSE 200   ' LCD nin kullanıma hazır hale gelebilmesi için gerekli süre 
lcdout $FE,1  
LCDOUT $FE,$80,"**Termometre**" 
LCDOUT $FE,$C0,"**_-_2009_-_**" 
pause 2000 
lcdout $FE,1  
;*******************************************************************************

basla:
gosub sensor
GOSUB disp
Gosub sov
;*******************************************************************************
sensor:

           OWOUT   io_Pin, 1, [$CC, $44]     '$CC ic romu atla.
Bekle:                                       '$44 sicakligi cevir
           OWIN    io_Pin, 4, [Busy]   
           IF      Busy = 0 THEN Bekle
           OWOUT   io_Pin, 1, [$CC, $BE]
           OWIN    io_Pin, 2, [HAM.Lowbyte, HAM.Highbyte]
           GOSUB   Hesapla
           RETURN
   
Hesapla:             
    Sign  = "+"
    IF SIGN_BITI = NEGAT_ISI THEN '11. bit isareti tutar
       Sign   = "-" 
       temp=($ffff-ham+1)*625
       ISI  = DIV32 10
       GOTO GEC   
    endif
    TEMP = 625 * (HAM+1)       
    ISI = DIV32 10         
GEC:
    FLOAT = (ISI //1000)/100
    ISI=ISI/1000
    RETURN 
;******************************************************************************
disp:
    lcdout $FE,$80,"SICAKLIK:",Sign,DEC ISI,".",DEC1 (Float),0,"C" 

    if ISI=65535 then  
        lcdout $FE,$80,"                   " 
        lcdout $FE,$80,"!!!SENSORU TAKIN!!!" 
    endif      
    RETURN        
        
;******************************************************************************
sov:
        if ISI < 20 then
         tR = 255
         tG = 0
         tB = 255
        ENDIF
        if ISI >= 20 && ISI < 21 then       
         tR = 255
         tG = 0
         tB = 255
        endif         
        if ISI >= 21 && ISI < 22 then
         tR = 204
         tG = 0
         tB = 255
        ENDIF
        if ISI >= 22 && ISI < 23 then
         tR = 153
         tG = 0
         tB = 255
        ENDIF
        if ISI >= 23 && ISI < 24 then
         tR = 102
         tG = 0
         tB = 255
        ENDIF
        if ISI >= 24 && ISI < 25 then
         tR = 51
         tG = 0
         tB = 255
        ENDIF
        if ISI >= 25 && ISI < 26 then
         tR = 0
         tG = 0
         tB = 255                           'mavi
        ENDIF
        if ISI >= 26 && ISI < 27 then
         tR = 0
         tG = 51
         tB = 255
        ENDIF
        if ISI >= 27 && ISI < 28 then
         tR = 0
         tG = 102
         tB = 255
        ENDIF
        if ISI >= 28 && ISI < 29 then
         tR = 0
         tG = 153
         tB = 255
        ENDIF
        if ISI >= 29 && ISI < 30 then
         tR = 0
         tG = 204
         tB = 255
        ENDIF
        if ISI >= 30 && ISI < 31 then
         tR = 0
         tG = 255
         tB = 255                           'turkuaz
        ENDIF
        if ISI >= 31 && ISI < 32 then
         tR = 0
         tG = 255
         tB = 204
        ENDIF
        if ISI >= 32 && ISI < 33 then
         tR = 0
         tG = 255
         tB = 153
        ENDIF
        if ISI >= 33 && ISI < 34 then
         tR = 0
         tG = 255
         tB = 102
        ENDIF
        if ISI >= 35 && ISI < 36 then
         tR = 0
         tG = 255
         tB = 0                             'yeşil
        ENDIF
       
        for a = 0 to 25
            for i = 0 to 255
       
            if i <= tR  THEN  PortA.1 = 1
            if i > tR then  PortA.1 = 0           
            if i <= tG  THEN PortA.2 = 1           
            if i > tG then PortA.2 = 0 
            if i <= tB  THEN PortA.3 = 1 
            if i > tB then  PortA.3 = 0 
            next i
        next a
        pauseus 20
GOTO basla


bu çalışan hex

:10000000B20154290408A700861086110611831630
:100010008610861106110F30860583122708B21844
:100020002E283A30A100FC30D7203330A6004220E1
:100030001030A1006830D72042206430D620223012
:10004000A600422028302D200C302D2001302D20FC
:1000500006302D20B21427082E283214A600321C98
:100060003C288611033C031C412841200530A10097
:10007000DC30D720031408003214FE3C03194F294A
:100080008615321C321086140F3086052608F0398A
:1000900086048610A60E321842282C30D62003146F
:1000A0000800083033190130A300A201360884008B
:1000B0003408C3203408800453215E2884130005CB
:1000C000FF3E331DA20C3319A20D3230D620A30BF4
:1000D0005828220803144F29A20008303319013090
:1000E000A300A20C360884003408C3203408031887
:1000F00080043730D62034088004A30B7128031401
:100100004F29B31C4F298728B300331C4F293608C9
:1001100084003408C3200130A100E030D720340827
:1001200080040130A100E030D728B3132908031957
:10013000B3170530A8002730A3001030AB200330E0
:10014000A300E830AB20A3016430AB20A3010A3048
:10015000AB202408B228A2002508A1002408A00092
:1001600018212008A000A8030319B31329080319B4
:10017000BC282802031808002008031DB313B31B72
:100180000800303E4A29FF3A8005C62884178005BA
:100190004F29A301A200FF30A207031CA307031CE1
:1001A0004F290330A100DF30D720CB28A101E83E42
:1001B000A000A109FC30031CE028A0070318DD28DB
:1001C000A0076400A10FDD282018E628A01CEA285B
:1001D0000000EA280800A2000330F328A20004303F
:1001E000F328A2000530A80023082102031DFA28E5
:1001F00022082002043003180130031902302805B8
:10020000031DFF304F290038031DFF300405031D77
:10021000FF304F29A2002008A6002408A0002608CD
:10022000A4002108A6002508A1002608A5001A2977
:10023000A501A4011030A600210DA40DA50D2208D2
:10024000A4022308031C230FA50203182E29220849
:10025000A40723080318230FA5070310A00DA10D61
:10026000A60B1C2920084F291030A800A101A001CD
:10027000A70CA60C031C42292208A0072308031878
:10028000230FA107A10CA00CA50CA40CA80B3829C6
:1002900024084F29840031088A0030088200831323
:1002A0000313831264000800FE3003204030032053
:1002B00006300320093003200930032006300320D4
:1002C00000300320003003200030032000300320E2
:1002D00007309F0083168113013085008601831249
:1002E000850186010130A300F430CA20061183166F
:1002F0000611FE308312032001300320C830C920CC
:10030000FE30032001300320FE3003208030032024
:100310002A3003202A300320543003206530032084
:10032000723003206D3003206F3003206D300320C6
:1003300065300320743003207230032065300320C1
:100340002A3003202A300320FE300320C03003204F
:100350002A3003202A3003205F3003202D30032071
:100360005F30032032300320303003203030032050
:10037000393003205F3003202D3003205F3003200D
:100380002A3003202A3003200730A300D030CA20AF
:10039000FE30032001300320CF216122F1220530FD
:1003A000B6000130B40001308420CC306C204430E1
:1003B0006C2081200530B6000130B4000430842068
:1003C0005120013903194410031D44148120640095
:1003D000441CDA290530B6000130B4000130842015
:1003E000CC306C20BE306C2081200530B60001304E
:1003F000B400023084205120BA005120BB0081207B
:10040000022208002B30C5006400BB1D252A2D30B8
:10041000C5003A08FF3CBE003B08031C013EFF3C00
:10042000BF00BE0A0319BF0A3E08A6003F08A70086
:100430007130A2000230A3003421C700A3010A30AA
:100440000A21BC002108BD003C2A01303A07BE0049
:100450003B080318013EBF007130A6000230A70020
:100460003E08A2003F08A3003421C700A3010A30C0
:100470000A21BC002108BD003C08A0003D08A100E5
:10048000E830A2000330A30018212408BE0025088C
:10049000BF003E08A0003F08A1006430A200A301F5
:1004A0001821B8002108B9003C08A0003D08A100AF
:1004B000E830A2000330A3001821BC002108BD00D1
:1004C0000800FE30032080300320533003204930E1
:1004D000032043300320413003204B3003204C30B5
:1004E0000320493003204B3003203A3003204508D5
:1004F0000320A9013C08A4003D08A5000230B0007B
:10050000B10195202E3003200130A9003808A40045
:100510003908A5000230B000B10195200030032059
:1005200043300320FF30A000FF30A1003D08A300AE
:100530003C08F120031DF02AFE3003208030032008
:1005400020300320203003202030032020300320DF
:1005500020300320203003202030032020300320CF
:1005600020300320203003202030032020300320BF
:1005700020300320203003202030032020300320AF
:10058000203003202030032020300320FE300320C1
:10059000803003202130032021300320213003202C
:1005A00053300320453003204E30032053300320C6
:1005B0004F300320523003205530032020300320D9
:1005C00054300320413003204B30032049300320B6
:1005D0004E3003202130032021300320213003201E
:1005E00008003C08A0003D08A100A3011430EB2046
:1005F000031DFF2AFF30C900C801FF30C6003C08B8
:10060000A0003D08A100A3011430EB20BE003C086F
:10061000A0003D08A100A3011530EE20C0003E0857
:10062000840040080321C000C10064004008410468
:1006300003191F2BFF30C900C801FF30C6003C085A
:10064000A0003D08A100A3011530EB20BE003C082E
:10065000A0003D08A100A3011630EE20C0003E0816
:10066000840040080321C000C10064004008410428
:1006700003193F2BCC30C900C801FF30C6003C082D
:10068000A0003D08A100A3011630EB20BE003C08ED
:10069000A0003D08A100A3011730EE20C0003E08D5
:1006A000840040080321C000C100640040084104E8
:1006B00003195F2B9930C900C801FF30C6003C0800
:1006C000A0003D08A100A3011730EB20BE003C08AC
:1006D000A0003D08A100A3011830EE20C0003E0894
:1006E000840040080321C000C100640040084104A8
:1006F00003197F2B6630C900C801FF30C6003C08D3
:10070000A0003D08A100A3011830EB20BE003C086A
:10071000A0003D08A100A3011930EE20C0003E0852
:10072000840040080321C000C10064004008410467
:1007300003199F2B3330C900C801FF30C6003C08A5
:10074000A0003D08A100A3011930EB20BE003C0829
:10075000A0003D08A100A3011A30EE20C0003E0811
:10076000840040080321C000C10064004008410427
:100770000319BE2BC901C801FF30C6003C08A00008
:100780003D08A100A3011A30EB20BE003C08A000E8
:100790003D08A100A3011B30EE20C0003E088400EC
:1007A00040080321C000C10064004008410403194F
:1007B000DE2BC9013330C800FF30C6003C08A00062
:1007C0003D08A100A3011B30EB20BE003C08A000A7
:1007D0003D08A100A3011C30EE20C0003E088400AB
:1007E00040080321C000C10064004008410403190F
:1007F000FE2BC9016630C800FF30C6003C08A000CF
:100800003D08A100A3011C30EB20BE003C08A00065
:100810003D08A100A3011D30EE20C0003E08840069
:1008200040080321C000C1006400400841040319CE
:100830001E2CC9019930C800FF30C6003C08A0003A
:100840003D08A100A3011D30EB20BE003C08A00024
:100850003D08A100A3011E30EE20C0003E08840028
:1008600040080321C000C10064004008410403198E
:100870003E2CC901CC30C800FF30C6003C08A000A7
:100880003D08A100A3011E30EB20BE003C08A000E3
:100890003D08A100A3011F30EE20C0003E088400E7
:1008A00040080321C000C10064004008410403194E
:1008B0005E2CC901FF30C800FF30C6003C08A00014
:1008C0003D08A100A3011F30EB20BE003C08A000A2
:1008D0003D08A100A3012030EE20C0003E088400A6
:1008E00040080321C000C10064004008410403190E
:1008F0007E2CC901FF30C800CC30C6003C08A000E7
:100900003D08A100A3012030EB20BE003C08A00060
:100910003D08A100A3012130EE20C0003E08840064
:1009200040080321C000C1006400400841040319CD
:100930009E2CC901FF30C8009930C6003C08A000B9
:100940003D08A100A3012130EB20BE003C08A0001F
:100950003D08A100A3012230EE20C0003E08840023
:1009600040080321C000C10064004008410403198D
:10097000BE2CC901FF30C8006630C6003C08A0008C
:100980003D08A100A3012330EB20BE003C08A000DD
:100990003D08A100A3012430EE20C0003E088400E1
:1009A00040080321C000C10064004008410403194D
:1009B000DD2CC901FF30C800C601C20164001A3035
:1009C000420203180C2DC301640043084902031CB2
:1009D000EA2C85146400430849020318F02C8510A2
:1009E000640043084802031CF62C05156400430804
:1009F00048020318FC2C0511640043084602031C3E
:100A0000022D85156400430846020318082D851140
:0E0A1000C30FE42CC20FDE2C1430D620CC29EC
:02400E00303F41
:00000001FF



mustafa_cmbz

realde rgb oluşumunda sorun yaşayabilirsin...titremeler vs şeyler olabilir...

ben yinede sağlıklı bişey yapılacaksa hardware pwm den yanayım...alayli hocam ile denemeler yaptık en kralı hpwm....

MC_Skywalker

pwm i nasıl yapacağımı bulamadığım için bu pwm e benzer yolu buldum. bilim teknik dergisindeki yazar bu formülü hi-tec C ile yapmış ona bakıp PBP ile yaptım.