Rem *************************************************
Rem * Wirtualna myszka *
Rem * *
Rem * Autor: Karol Gnyś *
Rem * Wersja: 1v1 *
Rem * Kompilator: Bascom AVR - 1.11.7.4 *
Rem * Rok:2007 *
Rem *************************************************
$regfile = "m8def.dat"
$crystal = 8000000
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Portc = Input
Config Portd = Output
Portd = &B00000000
Config Pinb.0 = Input
Hold Alias Pinb.0
Set Portb.0
Dim Stopp As Bit
Dim Kanal As Word
Dim Kanal2 As Word
Dim Kanal1 As Word
Start Adc
Portd.0 = 0
Portd.1 = 0
Portd.2 = 0
Portd.3 = 0
Do
Kanal1 = Getadc(0)
Kanal2 = Getadc(1)
If Kanal1 >= Kanal2 Then
Kanal = Kanal1
Else
Kanal = Kanal2
End If
If Hold = 0 Then
Waitms 25
If Hold = 0 Then
Toggle Stopp
If Stopp = 0 Then
Stop Adc
End If
If Stopp = 1 Then
Start Adc
End If
End If
End If
If Kanal1 >= 550 And Kanal1 <= 1024 Then
Gosub Prawo
End If
If Kanal1 >= 0 And Kanal1 <= 450 Then
Gosub Lewo
End If
If Kanal2 >= 550 And Kanal2 <= 1024 Then
Gosub Gora
End If
If Kanal2 >= 0 And Kanal2 <= 450 Then
Gosub Dol
End If
Loop
Prawo:
Toggle Portd.0
Toggle Portd.1
Return
Lewo:
Toggle Portd.1
Toggle Portd.0
Return
Gora:
Toggle Portd.2
Toggle Portd.3
Return
Dol:
Toggle Portd.3
Toggle Portd.2
Return