Was für fehlermeldungen?
Ich habe den Code nochmal an zwei Stellen bearbeitet:
In der Zeile "Result > 1000" ist es nicht sinnvoll = zu verwenden, da er nur bei diesem Wert hinter fährt. Von daher ist es sinnvoll " > "einzusetzten. Dann fährt er bei ganz nahen Gegenständen zurück.Code: [Ansicht]$regfile = "m8def.dat" $crystal = 16000000 Dim Result As Word Dim Channel As Byte Config Pinb.1 = Output Config Pinb.2 = Output Config Pinc.0 = Output Config Pinc.1 = Output Config Pinc.2 = Output Config Pinc.3 = Output Config Pinc.4 = Input Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up , Prescale = 1 Config Adc = Single , Prescaler = Auto , Reference = Avcc Compare1a = 1 Compare1b = 1 Portc.0 = 1 Portc.1 = 0 Portc.2 = 1 Portc.3 = 0 Start Adc Do Result = Getadc(4) ; Result If Result > 1000 Then Portc.0 = 0 Portc.1 = 1 Portc.2 = 0 Portc.3 = 1 Wait 1 Loop End
jon