Pisze sterownik wytrawiarki. Napisałem część bez pompki napowietrzającej. Proszę kogoś doświadczonego o sprawdzenie czy nie ma w nim błędów.
Dodam że dopiero zaczynam pisać programy z książką M. Wiazania.
Code:
$regfile = "m8def.dat"
$crystal = 8000000
Dim A As Byte 'obecna
Dim D As Byte 'zadana
D = 40
Dim E As Byte
E = 120 'czas
Pinb.1 = Input 'up temperatura
Reset Pinb.1 = 0
Pinb.2 = Input 'down temperatura
Reset Pinb.2 = 0
Pinb.3 = Input 'czas +
Reset Pinb.3 = 0
Pinb.4 = Input 'czas -
Reset Pinb.4 = 0
Pinb.5 = Output 'buzzer
Reset Pinb.5 = 0
Pinb.6 = Input 'grzalka na przekaznik
Reset Pinb.6 = 0
Deflcdchar 0 , 32 , 32 , 7 , 4 , 4 , 31 , 14 , 4 'do konca
Deflcdchar 1 , 4 , 10 , 10 , 10 , 10 , 17 , 31 , 14 'temperatura
Deflcdchar 2 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32 'zank stopnia
Deflcdchar 3 , 14 , 17 , 21 , 21 , 23 , 17 , 17 , 14 'zegar do czasu
Cls 'czyszcenie po definiowaniu
If Pinb.1 = 1 Then D + 1
Waitms 80
End If
If Pinb.2 = 1 Then D - 1
Waitms 80
End If
If Pinb.3 = 1 Then E + 20
Waitms 80
End If
If Pinb.4 = 1 Then E - 20
Waitms 80
End If
Do E -1 Wait 1 Loop [until E = 0]
If E = 0 Then Pinb.5 = 1 Wait 2
End If
If E > 1 Then Pinb.6 = 1
Elseif E = 0 Then Pinb.6 = 0
End If
'**************właczenie przetwornika****************
Config Adc = Single , Prescaler = Auto , Reference = Internal
A = Getadc(0) * 3 'odczyt z kanału 0 razy 3
'*****************CONFIG LCD*******************
Config Lcd = 16 * 2
Config Lcdpin = Pin ,
Db4 = Portc.3 ,
Db5 = Portc.2 ,
Db6 = Portc.1 ,
Db7 = Portc.0 ,
E = Portc.4 ,
Rs = Portc.5
'******************powitanie********
Cls
Locate 1 , 5
Lcd "Witamy"
Waitms 350
Cls
'******LCD*******************
Locate 1 , 1
Lcd Chr(1)
Locate 1 , 3
Lcd A
Locate 1 , 5
Lcd Chr(2) ; "C"
Locate 1 , 8
Lcd D
Locate 2 , 1
Lcd Chr(3)
Locate 2 , 3
Lcd E
Locate 2 , 7
Lcd Chr(0)
Locate 2 , 9
If E > 0 Then Lcd "run" 'grzalka on
Elseif E = 0 Then Lcd "no run" 'grzelka off
Dodam że dopiero zaczynam pisać programy z książką M. Wiazania.