'Batarya azaldığında sırasıyla ledler yanar. '**************************************************************** '* Name : led_el feneri.BAS * '* Author : Şinasi Yavuz ] * '* : All Rights Reserved * '* Date : 26.11.2010 * '* Version : 1.0 * 'ANSEL = 110001 'ADCON0 = %10000001 '**************************************************************** include "modedefs.bas" '@ DEVICE pic16F628a,xt_OSC,mclr_off @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT,mclr_off DEFINE LOADER_USED 1 define osccal_1k 1 'define osc 4 led_1 var gpio.0 ' b0 Var GPIO.2 ' serial test için 'AN1 için gpio.1 Lamba var gpio.2 Buton var gpio.3 led_2 var gpio.5 led_3 var gpio.4 Define ADC_BITS 10 ' Set number of bits in result Define ADC_CLOCK 3 ' Set clock source (3=rc) Define ADC_SAMPLEUS 50 ' Set sampling time in uS raw var word 'ADC den okunan ham Digital değer. VOLT var word '16 bit değişken tipi seçtik kullanacağımız değer 10 bit olacak. Mvolt var byte OSCCAL=$3438 ' Yeni Kasım 2010 calib high lamba high led_1 high led_2 high led_3 pause 2000 '****************************************basla************************ 'ANSEL = 110001 'ADCON0 = %10000001 ADCON0.7 = 1 ' Right justify result ANSEL = 000010 ' Set AN1 analog, rest digital CMCON = 7 ' Analog comparators off 'TmpW = Vbatt * Vfs 'AD * 20480 ' TmpW = Div32 1024 '(AD * 20480) / 1024 '********************************************************************** loop: if buton=0 and volt>=3 then toggle lamba pause 200 if volt=<2 then low lamba ADCIN 1, raw ' adcin 1, volt '***************Bu 3 satır iyi durumda**************** Volt=(Raw*/1250)/100 MVolt=Volt//10 ' Mvolt = Volt mod 10 Volt=Volt/10 '************************************* 'and mvolt=<0 'Serout b0, n2400, ["DC Volts= ", #volt,".", #mvolt,10,13] 'test halinde 'Serout b0, n2400, ["DC Volts= ", #volt,".", #mvolt] 'yan yana ' Pause 100 ' Wait .1 second if volt=<3 and mvolt=<8 or volt=<2 then 'mvolt=<8 or volt=<2 then high led_1 else low led_1 endif if volt=<3 and mvolt=<5 or volt=<2 then 'mvolt=<5 or volt=<2 then high led_2 else low led_2 endif if volt=<3 and mvolt=<1 or volt=<2 then 'mvolt=<1 or volt=<2 then high led_3 else low led_3 endif ' flaşör 3 led birden if volt=<2 and mvolt=<3 or volt=<1 then high led_1:high led_2:high led_3 pause 20 low led_1:low led_2:low led_3 pause 70 else endif GoTo loop '************************************************************************** END |
6 Ekim 2013 Pazar
Posted by Adsız on 08:57
with No comments so far
Kaydol:
Kayıt Yorumları (Atom)
0 yorum:
Yorum Gönder