Hallo,
ich habe versucht ein Programm zu machen, das die Bee nicht vom Tisch fallen lässt:
Code:
'Verwendeter Compiler Bascom V 1.11.9.7
'
'Aufgabe:
'NIBOBee fällt nicht vom Tisch
'Autor: Pinsel120866
'###################################################
$regfile = "m16def.dat"
$crystal = 15000000
$hwstack = 32
$swstack = 8
$framesize = 24
Lineled Alias Portb.4
Config Lineled = Output ' Lineled
Config Adc = Single , Prescaler = 64 , Reference = Avcc ' 235 kHz
Declare Sub Motorpwm(byval Pwm_l As Byte , Byval Pwm_r As Byte)
Declare Sub Motordir(byval Dir_l As Byte , Byval Dir_r As Byte)
Declare Sub Frontled(byval Ledstatus As Byte)
Declare Sub Linedata()
Dim Linesensl As Integer
Dim Linesensc As Integer
Dim Linesensr As Integer
Start Adc
Wait 3
Do
Call Frontled(0)
Call Linedata
If Linesensl > 30 Or Linesensc > 30 Or Linesensr > 30 Then
Call Motordir(0 , 0)
Call Motorpwm(0 , 0)
Waitms 500
Call Motordir(0 , 0)
Call Motorpwm(100 , 100)
Waitms 500
Call Motordir(1 , 0)
Call Motorpwm(100 , 100)
Waitms 500
Call Motordir(1 , 1)
Call Motorpwm(100 , 100)
Else
Call Motordir(1 , 1)
Call Motorpwm(100 , 100)
End If
Loop
End
Sub Motorpwm(byval Pwm_l As Byte , Byval Pwm_r As Byte)
Pwm1a = Pwm_l * 4
Pwm1b = Pwm_r * 4
End Sub
Sub Motordir(byval Dir_l As Byte , Byval Dir_r As Byte)
If Dir_l = 0 Then Portd.6 = 0 Else Portd.6 = 1
If Dir_r = 0 Then Portd.7 = 1 Else Portd.7 = 0
End Sub
Sub Frontled(byval Ledstatus As Byte) ' LED für Liniensensor ein-/aus-schalten
Ddrb.4 = 1
Portb.4 = Ledstatus.0
End Sub
Sub Linedata() ' Liniensensoren lesen
Config Portb.4 = Output
Portb.4 = 1
Linesensl = Getadc(5)
Linesensc = Getadc(6)
Linesensr = Getadc(7)
Portb.4 = 0
End Sub
Lässt sich fehlerfrei kompilieren und flashen, aber die Bee rührt sich nicht.
Warum?
Bitte um Hilfe.
Lesezeichen