$crystal = 16000000
$regfile = "m32def.dat"
'Long
Dim Moc As Word
Dim Czas As Word
Declare Sub Keyboard
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Porta.5 , Db5 = Porta.4 , Db6 = Porta.3 , Db7 = Porta.2 , E = Porta.6 , Rs = Porta.7
Cursor Off
Cls
Config Pinb.3 = Output
Config Pind.6 = Output
Bramka Alias Portb.3
Buzzer Alias Portd.6
Set Buzzer
Set Bramka
'konfiguracja klawiatury
Config Pinb.7 = Input
Config Pinb.6 = Input
Config Pinb.5 = Input
Config Pinb.4 = Input
Key_up Alias Pinb.4
Key_down Alias Pinb.5
Key_min Alias Pinb.6
Key_max Alias Pinb.7
Moc = 1
Czas = 2341
Config Timer1 = Timer , Prescale = 64
On Timer1 Odpal_triak:
Stop Timer1
On Int0 Zero_sieci:
Config Int0 = Rising
Enable Timer1
Enable Int0
Enable Interrupts
Do
Keyboard
Lcd Moc ; "%"
Locate 2 , 1
Lcd Czas
Waitms 200
Cls
Loop
End
Zero_sieci:
Load Timer1 , Czas
Start Timer1
Return
Odpal_triak:
Disable Int0
Stop Timer1
Reset Bramka
Waitus 10
Set Bramka
Enable Int0
Return
Tabela:
Data 2341% , 2274% , 2223% , 2180% , 2141% , 2106% , 2074% , 2044% , 2015% , 1988%
Data 1962% , 1937% , 1913% , 1890% , 1867% , 1845% , 1824% , 1803% , 1782% , 1762%
Data 1742% , 1723% , 1704% , 1685% , 1667% , 1648% , 1630% , 1613% , 1595% , 1577%
Data 1560% , 1543% , 1526% , 1509% , 1492% , 1476% , 1459% , 1443% , 1427% , 1410%
Data 1394% , 1378% , 1362% , 1346% , 1330% , 1314% , 1298% , 1282% , 1266% , 1250%
Data 1234% , 1218% , 1202% , 1186% , 1170% , 1154% , 1138% , 1122% , 1106% , 1090%
Data 1073% , 1057% , 1041% , 1024% , 1008% , 991% , 974% , 957% , 940% , 923%
Data 905% , 887% , 870% , 852% , 833% , 815% , 796% , 777% , 758% , 738%
Data 718% , 697% , 676% , 655% , 633% , 610% , 587% , 563% , 538% , 512%
Data 485% , 456% , 426% , 394% , 359% , 320% , 277% , 226% , 159% , 64% , 1%
Sub Keyboard
If Key_max = 0 Then
Moc = 100
Reset Buzzer
Waitms 50
Set Buzzer
End If
If Key_min = 0 Then
Moc = 1
Reset Buzzer
Waitms 50
Set Buzzer
End If
If Key_up = 0 Then
Incr Moc
If Moc > 99 Then
Moc = 100
End If
Reset Buzzer
Waitms 50
Set Buzzer
End If
If Key_down = 0 Then
Decr Moc
If Moc < 1 Then
Moc = 1
End If
Reset Buzzer
Waitms 50
Set Buzzer
End If
Czas = Lookup(moc , Tabela)
End Sub