tuttaj wkleje czesc kodu jaki napisalem ale jakos mi to nie specjalnie dziala nie wiem dlaczego a muszeto zaliczyc bo mnie ukiapa na semestr moge liczyc na wasza pomoc??
Kod: Zaznacz cały
$large
On Int0 Wrzucono_monete
On Int1 Wcisnieto_przycisk
Enable Interrupts
Enable Int0
Enable Int1
Declare Sub Wydaj_reszte
'P3.0 - P3.5 - (wejscia)
'P1.0 - P1.5 - (wyjscia)
Dim Kasa As Byte
Dim Temp1 As Word
Dim Temp2 As Byte
Dim Temp3 As Byte
P3 = 0
Temp3 = 0
Config Lcd = 16 * 2
Cls
P1 = 0
Lcd "Wybierz baton"
Do
If Temp3 > 0 Then
If Temp3 = 1 Then
Temp1 = Kasa / 10
Temp2 = Kasa Mod 10
Cls
Lcd "Kwota: " ; Temp1 ; "," ; Temp2 ; "0 zl"
End If
Decr Temp3
End If
Delay
Loop
Wrzucono_monete:
P1 = 0
' 10 gr
If P3.0 = 1 Then
Kasa = Kasa + 1
End If
' 20 gr
If P3.1 = 1 Then
Kasa = Kasa + 2
End If
' 50 gr
If P3.2 = 1 Then
Kasa = Kasa + 5
End If
' 1 zl
If P3.3 = 1 Then
Kasa = Kasa + 10
End If
' 2 zl
If P3.4 = 1 Then
Kasa = Kasa + 20
End If
' 5 zl
If P3.5 = 1 Then
Kasa = Kasa + 50
End If
Temp1 = Kasa / 10
Temp2 = Kasa Mod 10
Cls
Lcd "Kwota: " ; Temp1 ; "," ; Temp2 ; "0 zl"
Return
Wcisnieto_przycisk:
' wyzerowanie
If P3.5 = 1 Then
Call Wydaj_reszte
End If
' Snikers - 1,00 zl
If P3.0 = 1 Then
If Kasa >= 10 Then
P1 = 0
Cls
Lcd "Snikers"
Waitms 300
Cls
Lcd "eat that"
P1 = 0
Set P1.7
Set P1.0
Waitms 100
P1 = 0
Delay
' wydawanie kasy
Kasa = Kasa - 10
Call Wydaj_reszte
Else
Temp1 = 10 - Kasa
Temp2 = Temp1 Mod 10
Temp1 = Temp1 / 10
Cls
Lcd "Brakuje: " ; Temp1 ; "," ; Temp2 ; "0 zl!"
Temp3 = 10
End If
End If
' Mars - 1,00 zl
If P3.1 = 1 Then
If Kasa >= 10 Then
P1 = 0
Cls
Lcd "Mars"
Waitms 300
Cls
Lcd "eat that"
' wyrzucanie batonow
P1 = 0
Set P1.7
Set P1.1
Waitms 100
P1 = 0
Delay
'wydawanie kasy
Kasa = Kasa - 10
Call Wydaj_reszte
Else
Temp1 = 10 - Kasa
Temp2 = Temp1 Mod 10
Temp1 = Temp1 / 10
Cls
Lcd "Brakuje: " ; Temp1 ; "," ; Temp2 ; " 0 zl!"
Temp3 = 10
End If
End If
' Milkiway 1,50 zl
If P3.2 = 1 Then
If Kasa >= 15 Then
P1 = 0
Cls
Lcd "Milkiway"
Waitms 300
Cls
Lcd "eat that"
' wyrzucanie batonow
P1 = 0
Set P1.7
Set P1.2
Waitms 100
P1 = 0
Delay
' wydawanie kasy
Kasa = Kasa - 15
Call Wydaj_reszte
Else
Temp1 = 15 - Kasa
Temp2 = Temp1 Mod 10
Temp1 = Temp1 / 10
Cls
Lcd "Brakuje: " ; Temp1 ; "," ; Temp2 ; "0 zl!"
Temp3 = 10
End If
End If
' Kitkat - 1,50 zl
If P3.3 = 1 Then
If Kasa >= 15 Then
P1 = 0
Cls
Lcd "kitkat"
Waitms 300
Cls
Lcd "udlaw sie"
' wyrzucanie batonow
P1 = 0
Set P1.7
Set P1.3
Waitms 100
P1 = 0
Delay
' wydawanie kasy
Kasa = Kasa - 15
Call Wydaj_reszte
Else
Temp1 = 15 - Kasa
Temp2 = Temp1 Mod 10
Temp1 = Temp1 / 10
Cls
Lcd "Brakuje: " ; Temp1 ; "," ; Temp2 ; "0 zl!"
Temp3 = 10
End If
End If
' 3bit - 1,20 zl
If P3.4 = 1 Then
If Kasa >= 12 Then
P1 = 0
Cls
Lcd "3bit"
Waitms 300
Cls
Lcd "eat that"
' wyrzucanie batonow
P1 = 0
Set P1.7
Set P1.4
Waitms 100
P1 = 0
Delay
' wydawanie kasy
Kasa = Kasa - 12
Call Wydaj_reszte
Else
Temp1 = 12 - Kasa
Temp2 = Temp1 Mod 10
Temp1 = Temp1 / 10
Cls
Lcd "Brakuje: " ; Temp1 ; "," ; Temp2 ; "0 zl!"
Temp3 = 10
End If
End If
Return
Sub Wydaj_reszte
P1 = 0
Temp1 = Kasa / 10
Temp2 = Kasa Mod 10
Cls
Lcd "Reszta: " ; Temp1 ; "," ; Temp2 ; "0 zl"
Waitms 100
P1 = 0
While Kasa > 0
Set P1.6
Temp1 = Kasa / 50
If Temp1 > 0 Then
Set P1.5
Kasa = Kasa - 50
End If
Temp1 = Kasa / 20
If Temp1 > 0 Then
Set P1.4
Kasa = Kasa - 20
End If
Temp1 = Kasa / 10
If Temp1 > 0 Then
Set P1.3
Kasa = Kasa - 10
End If
Temp1 = Kasa / 5
If Temp1 > 0 Then
Set P1.2
Kasa = Kasa - 5
End If
Temp1 = Kasa / 2
If Temp1 > 0 Then
Set P1.1
Kasa = Kasa - 2
End If
Temp1 = Kasa / 1
If Temp1 > 0 Then
Set P1.0
Kasa = Kasa - 1
End If
Waitms 200
Cls
P1 = 0
Delay
Wend
Temp1 = Kasa / 10
Temp2 = Kasa Mod 10
Cls
Lcd "Kwota: " ; Temp1 ; "," ; Temp2 ; "0 zl"
End Sub