$regfile = "m8def.dat"
$crystal = 12000000
'KONFIGURACJA PORTÓW'
Config Portd.0 = Input 'PRZELACZNIK'
Config Portd.1 = Output 'BUZZER'
Config Portd.3 = Input 'TSOP'
Config Portc = Input '6 x CNNY70'
Config Portb.0 = Output
Config Portb.1 = Output
Config Portb.2 = Output
Config Portb.3 = Output
Config Portb.4 = Output
Config Portb.5 = Output 'L293D - > SILNIKI'
'KONFIGURACJA STANÓW SPOCZYNKOWYCH'
Portd.0 = 1 'PRZEŁĄCZNIK, JEŚLI 0 -> WCIŚNIĘTY'
Portd.1 = 1 'BUZZER, JEŚLI 0 -> WŁĄCZONY'
Portd.3 = 1 'TSOP1737, JEŚLI 0 -> PODAWANY JEST SYGNAŁ'
Portc = &B1111111 'CZUJNIKI CNY70 (1 = BRAK LINI POD CZUJNIKIEM)
Portb.0 = 0
Portb.1 = 1 'PWM'
Portb.2 = 1 'PWM'
Portb.3 = 1
Portb.4 = 1
Portb.5 = 0 'SILNIKI WYŁĄCZONE'
Buzzer Alias Portd.1 'NAZWY POMOCNICZE'
Przelacznik Alias Pind.0 'NAZWY POMOCNICZE'
Tsop Alias Pind.3 'NAZWY POMOCNICZE'
Config Adc = Single , Prescaler = Auto , Reference = Avcc 'KONFIGURACJA ADC
Start Adc
Config Timer1 = Pwm , Prescale = 1 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down 'konfiguracja timera1
Dim Wart_adc As Word 'ZCZYTYWANIE WARTOŚCI Z PORTU DO WART_AC'
Dim Stan_czujnikow As Byte 'KONCOWA WARTOŚĆ Z ODCZYTU'
Dim Sygnal As Byte
Declare Sub Uruchom
Declare Sub Przygotuj
Declare Sub Jedz
Declare Sub Ostatnia
Declare Sub Prosto
Declare Sub Prawo_bardzo_lekko
Declare Sub Lewo_bardzo_lekko
Declare Sub Lekko_prawo
Declare Sub Lekko_lewo
Declare Sub Prawo
Declare Sub Lewo
Declare Sub Mocno_prawo
Declare Sub Mocno_lewo
Declare Sub Bardzo_mocno_prawo
Declare Sub Bardzo_mocno_lewo
'Start'
call przygotuj
Do
Wart_adc = Getadc(0)
If Wart_adc <= 600 Then
Stan_czujnikow.0 = 1
Else
Stan_czujnikow.0 = 0
End If
Wart_adc = Getadc(1)
If Wart_adc <= 600 Then
Stan_czujnikow.1 = 1
Else
Stan_czujnikow.1 = 0
End If
Wart_adc = Getadc(2)
If Wart_adc <= 600 Then
Stan_czujnikow.2 = 1
Else
Stan_czujnikow.2 = 0
End If
Wart_adc = Getadc(3)
If Wart_adc <= 600 Then
Stan_czujnikow.3 = 1
Else
Stan_czujnikow.3 = 0
End If
Wart_adc = Getadc(4)
If Wart_adc <= 600 Then
Stan_czujnikow.4 = 1
Else
Stan_czujnikow.4 = 0
End If
Wart_adc = Getadc(5)
If Wart_adc <= 600 Then
Stan_czujnikow.5 = 1
Else
Stan_czujnikow.5 = 0
End If
'porownaj'
If Stan_czujnikow = &B110011 Then
Call Prosto
End If
If Stan_czujnikow = &B110001 Then
call Prawo_bardzo_lekko
End If
If Stan_czujnikow = &B100011 Then
Call Lewo_bardzo_lekko
End If
If Stan_czujnikow = &B111001 Then
Call Lekko_prawo
End If
If Stan_czujnikow = &B100111 Then
Call Lekko_lewo
End If
If Stan_czujnikow = &B011001 Then
Call Prawo
End If
If Stan_czujnikow = &B100110 Then
Call Lewo
End If
If Stan_czujnikow = &B011101 Then
Call Mocno_prawo
End If
If Stan_czujnikow = &B101110 Then
Call Mocno_lewo
End If
If Stan_czujnikow = &B011111 Then
Call Bardzo_mocno_prawo
End If
If Stan_czujnikow = &B111110 Then
Call Bardzo_mocno_lewo
End If
If Stan_czujnikow = &B111111 Then
Call Prosto
End If
If Stan_czujnikow = &B111011 Then
Call Lekko_prawo
End If
If Stan_czujnikow = &B110111 Then
Call Lekko_lewo
End If
If Stan_czujnikow = &B111101 Then
Call Prawo
End If
If Stan_czujnikow = &B101111 Then
Call Lewo
End If
Loop
End
Prosto:
Pwm1a = 255
Pwm1b = 255
Return
Prawo_bardzo_lekko:
Pwm1a = 255
Pwm1b = 190
Return
Lewo_bardzo_lekko:
Pwm1a = 190
Pwm1b = 255
Return
Lekko_prawo:
Pwm1a = 255
Pwm1b = 150
Return
Lekko_lewo:
Pwm1a = 150
Pwm1b = 255
Return
Prawo:
Pwm1a = 255
Pwm1b = 100
Return
Lewo:
Pwm1a = 100
Pwm1b = 255
Return
Mocno_prawo:
Pwm1a = 255
Pwm1b = 50
Return
Mocno_lewo:
Pwm1a = 50
Pwm1b = 255
Return
Bardzo_mocno_prawo:
Pwm1a = 255
Pwm1b = 0
Return
Bardzo_mocno_lewo:
Pwm1a = 0
Pwm1b = 255
Return
Przygotuj:
Reset Buzzer
Waitms 50
Set Buzzer
Waitms 50
Reset Buzzer
Waitms 50
Set Buzzer
Waitms 50
Reset Buzzer
Waitms 50
Set Buzzer
Waitms 5
return
tak powinno być git 😉