$regfile = "m8def.dat"
$crystal = 8000000
$hwstack = 100
$swstack = 100
$framesize = 100
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , _
Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Config Lcd = 16 * 2
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
Config Timer1 = Timer , Prescale = 8
Enable Timer1
On Timer1 Takt
Enable Interrupts
Timer1 = 65534
Dim Licht1 As Integer
Dim Licht2 As Integer
Dim Licht3 As Integer
Dim Licht4 As Integer
Dim X As Bit
Dim Y As Word
Config Single = Scientific , Digits = 4
Dim Geschwindigkeit As Single
Licht3 = Getadc(4)
Licht4 = Getadc(5)
Cls
Do
Licht1 = Getadc(4) + 2
If Licht1 < Licht3 Then X = 0
Licht2 = Getadc(5) + 2
If Licht2 < Licht4 Then X = 1
If X = 0 And Y > 0 Then
Geschwindigkeit = 60000 / Y
Locate 2 , 2
Lcd Geschwindigkeit ; "m/S"
Y = 0
Waitms 30
Cls
End If
Loop
End
Takt:
Timer1 = 65534
If X = 1 Then Incr Y
Return
Lesezeichen