$regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 64
$swstack = 64
$framesize = 128
$prog &HFF , &HFF , &HDE , &HFD ' generated. Take care that the chip supports all fuse bytes.
Debug Off
'--------------------------------------------------------------------
'KONFIGURACJA LCD
Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portc.5 'mirley UPT M16
Config Lcd = 20 * 4
'--------------------------------------------------------------------
'KONFIGURACJA TIMER1
Config Timer1 = Timer , Prescale = 8
Enable Timer1 : On Timer1 Przertimer1
Enable Interrupts
'--------------------------------------------------------------------
'KONFIGURACJA PORTÓW
Config Portb.5 = Output : Portb.5 = 1
Config Portd.2 = Input : Pind.2 = 1
Config Portd.3 = Input : Pind.3 = 1
Config Portd.4 = Input : Pind.4 = 1
Config Portd.7 = Output
Config Print = Portd.7 , Mode = Set
'--------------------------------------------------------------------
Deflcdchar 0 , 6 , 9 , 9 , 6 , 32 , 32 , 32 , 32 'znak stopnia C
Deflcdchar 1 , 14 , 17 , 17 , 31 , 17 , 17 , 17 , 2 'litera Ą
Deflcdchar 2 , 9 , 10 , 12 , 8 , 24 , 8 , 15 , 32 ' litera Ł
Deflcdchar 3 , 4 , 4 , 10 , 10 , 10 , 17 , 17 , 31 ' ikona delty
'--------------------------------------------------------------------
'KONFIGURACJA PORTU COM
$baud = 57600
Config Serialin = Buffered , Size = 100
Config Serialout = Buffered , Size = 100
'--------------------------------------------------------------------
Config Portd.7 = Output
Config Print = Portd.7 , Mode = Set
'--------------------------------------------------------------------
'ALIASY PORTÓWa
Arduino_led Alias Portb.5 'LED na płytce Arduino
'--------------------------------------------------------------------
'ZMIENNE KOMUNIKACJI
Dim Ile_elementow As Byte '
Dim Znak_ As Byte
Dim Uart_komenda As String * 20 'musi byc wystarczjaco dlugie
Dim Getcommands(10) As String * 10 'tablica na pociete komendy
'--------------------------------------------------------------------
'ZMIENNE CZASU
Dim Dziel(6) As Byte
Dim Flaga10ms As Bit
Dim Flaga100ms As Bit
Dim Flaga500ms As Bit
Dim Flaga1s As Bit
Dim Flaga2s As Bit
Dim Flaga10s As Bit
'--------------------------------------------------------------------
Dim A As Bit
'--------------------------------------------------------------------
'DEKLARACJE PODPROGRAMÓ
Declare Sub Wyswietl
Declare Sub Mruganie
'--------------------------------------------------------------------
Cursor Off Noblink
Wait 2
Cls
Call Wyswietl
'--------------------------------------------------------------------
'PĘTLA GŁÓWNA
Do
If Flaga10ms = 1 Then 'co 10 ms
Flaga10ms = 0 'wyzeruj Flaga10ms
End If
If Flaga100ms = 1 Then 'co 100ms
Flaga100ms = 0
Call Wyswietl 'wyzeruj Flaga100ms
End If
If Flaga500ms = 1 Then 'co 50ms
Flaga500ms = 0 'wyzeruj Flaga500ms
End If
If Flaga1s = 1 Then 'co1s
Flaga1s = 0
Toggle A
Print A
Call Mruganie 'wyzeruj Flaga1s '
End If
If Flaga2s = 1 Then 'co2s
Flaga2s = 0 'wyzeruj Flaga2s
End If
If Flaga10s = 1 Then 'co10s
Flaga10s = 0 'wyzeruj Flaga10s
End If
Loop
End
'--------------------------------------------------------------------
'Wyświetlanie
Sub Wyswietl
Locate 1 , 1 : Lcd "A: " ; A
End Sub
'--------------------------------------------------------------------
'MRUGANIE DIODĄ LED CO 1 SEKUNDĘ
' CO BY BYŁO WIDAĆ ŻE UKŁAD ŻYJE
Sub Mruganie
Toggle Arduino_led
End Sub
'--------------------------------------------------------------------
' podprogram przerwań Timer1
Przertimer1:
Timer1 = 45536 'wstawienie do Timer1 wartości 45536
Incr Dziel(1) 'zwiększaj dzielnik 1
If Dziel(1) = 1 Then 'jeśli dzielnik 1 zwiększy się 1 razy
Dziel(1) = 0 'wyzeruj dzielnik 1
Set Flaga10ms 'ustaw Flaga10ms
Incr Dziel(2) 'zwiększaj dzielnik 2
If Dziel(2) = 10 Then 'jeśli dzielnik 2 zwiększy się 10 razy
Dziel(2) = 0 'wyzeruj dzielnik 2
Set Flaga100ms 'ustaw Flaga100ms
Incr Dziel(3) 'zwiększaj dzielnik 3
If Dziel(3) = 5 Then 'jeśli dzielnik 3 zwiększy się 5 razy
Dziel(3) = 0 'wyzeruj dzielnik 3
Set Flaga500ms 'ustaw Flaga500ms
Incr Dziel(4) 'zwiększaj dzielnik 4
If Dziel(4) = 2 Then 'jeśli dzielnik 4 zwiększy się 2 razy
Dziel(4) = 0 'wyzeruj dzielnik 4
Set Flaga1s 'ustaw Flaga1s
Incr Dziel(5) 'zwiększaj dzielnik 5
If Dziel(5) = 2 Then 'jeśli dzielnik 5 zwiększy się 2 razy
Dziel(5) = 0 'wyzeruj dzielnik 5
Set Flaga2s 'ustaw Flaga2s
Incr Dziel(6) 'zwiększaj dzielnik 6
If Dziel(6) = 5 Then 'jeśli dzielnik 6 zwiększy się 5 razy
Dziel(6) = 0 'wyzeruj dzielnik 6
Set Flaga10s ' Ustaw Flaga10s
End If 'koniec warunku
End If 'koniec warunku
End If 'koniec warunku
End If 'koniec warunku
End If 'koniec warunku
End If 'koniec warunku
Return 'powrót
'' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -