tako da za tastere promeni kod na
Code: Select all
button PORTA.0, 0, 120, 10, B1, 0, lblDole
button PORTA.1, 0, 120, 10, B1, 0, lblGore
button PORTA.2, 0, 120, 10, B1, 0, lblset
Moderators: pedja089, stojke369, [eDo], trax
Code: Select all
button PORTA.0, 0, 120, 10, B1, 0, lblDole
button PORTA.1, 0, 120, 10, B1, 0, lblGore
button PORTA.2, 0, 120, 10, B1, 0, lblset
DEFINE LCD_BITS 4
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 5
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 4
DEFINE LCD_LINES 2
pause 100 'cekanje inicijalizacije displeja
lcdout $fe,1, "pozdrav svima"
SYMBOL TASTER1= PORTA.0
SYMBOL TASTER2= PORTA.1
SYMBOL TASTER3= PORTA.2
B1 var byte : B1 = 0
B2 var byte : B2 = 0
B3 var byte : B3 = 0
INPUT TASTER1 ' sada smo taster proglasili ulazom
INPUT TASTER2
INPUT TASTER3
pocetak:
button PORTA.0, 0, 120, 10, B1, 1, lblDole
button PORTA.1, 0, 120, 10, B2, 1, lblGore
button PORTA.2, 0, 120, 10, B3, 1, lblset
GOTO pocetak
lblGore:
pause 100
LCDOUT $FE, 1 ;briše sve sa LCD-a
lcdout $fe,1, "gore"
GOTO pocetak
lblDole:
pause 100
LCDOUT $FE, 1 ;briše sve sa LCD-a
lcdout $fe,1, "dole"
GOTO pocetak
lblset:
pause 100
LCDOUT $FE, 1 ;briše sve sa LCD-a
lcdout $fe,1, "set"
GOTO pocetak
end
Code: Select all
DEFINE LCD_BITS 4 ' LCD broj Bita na liniji 4 ili 8
DEFINE LCD_DREG PORTB ' LCD data port
DEFINE LCD_DBIT 0 ' LCD pocetni bit podataka 0 ili 4(od kojeg pina na mikrokontroleru pocinje 0 bit podataka)
DEFINE LCD_RSREG PORTB ' LCD registar select port
DEFINE LCD_RSBIT 4 ' LCD registar select bit (na koji pin na mikrokontroleru je povezan RS bit)
DEFINE LCD_EREG PORTB ' LCD enable port
DEFINE LCD_EBIT 5 ' LCD enable bit(na koji pin na mikrokontroleru je povezan E bit)
DEFINE LCD_LINES 2
pause 100 'cekanje inicijalizacije displeja
lcdout $fe,2, "pozdrav svima"
trisc=0
pocetak:
if portc.0=1 then lblGore
if portc.1=1 then lblDole
if portc.2=1 then lblset
GOTO pocetak
lblGore:
pause 100
LCDOUT $FE, 1 ;briše sve sa LCD-a
lcdout $fe,1, "gore"
GOTO pocetak
lblDole:
pause 100
LCDOUT $FE, 1 ;briše sve sa LCD-a
lcdout $fe,1, "dole"
GOTO pocetak
lblset:
pause 100
LCDOUT $FE, 1 ;briše sve sa LCD-a
lcdout $fe,1, "set"
GOTO pocetak
end
Code: Select all
ADCON1 = %00000111
Code: Select all
DEFINE LCD_BITS 4
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 3
DEFINE LCD_LINES 2
DEFINE LCD_DATAUS 40
Code: Select all
symbol DQ = PORTb.2 ' Dq linija je povez. na pin RE2
temperatura Var Word ' Promen.za cuvanje izmer. temp.
count_remain Var Byte ' Ostatak
count_per_c Var Byte ' Ostatak po stepenu C
Pause 100 ' Pauza za start LCD-a
Pocetak:
OWOut DQ, 1, [$CC, $44] ' Start merenja temperature
Cekaj: OWIn DQ, 4, [count_remain] ' Provera da li jos traje
If count_remain = 0 Then Cekaj
OWOut DQ, 1, [$CC, $BE] ' Procitaj izmerenu temperaturu
OWIn DQ, 0, [temperatura.LOWBYTE, temperatura.HIGHBYTE, Skip 4, count_remain, count_per_c]
' Prikazi temperaturu u DEC obliku
temperatura = (((temperatura >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)
Lcdout $fe, 1, " TEMPERATURA"
Lcdout $fe, $C0, " ", DEC (temperatura / 100), ".", DEC2 temperatura, " C"
Pause 5000 ' Zadrzi pet sekundi
GoTo Pocetak ' Ponovi sve
End ' Kraj programa