Benutze die Format Funktion:

Code:
$regfile = "m8def.dat"
$crystal = 3686400
'$baud = 9600


Dim Result As Word
'Dim Channel As Byte

'Dim Licht As Word

Config Lcd = 16 * 2

'Dim N As Integer
Dim Test(2) As String * 2

Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2

Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up , Prescale = 1

Config Portb = Output
Portb = &HFF


Config Adc = Single , Prescaler = Auto , Reference = Avcc
'Set Sfior.adhsm


Cls

Lcd "Facharbeit-PWM"

Wait 1

Cls

Lcd "PWM"

Start Adc

Do

   Result = Getadc(0)                                      'Analogwert wird auf c.0 eingelesen

   Result = Result / 4                                      'Teiler 1024/4

   Compare1a = Result                                   'Zählerstand als PWM
   Test(1) = Str(result)
   Test(2) = Format(test(1) , "000")
   Lowerline


   Lcd "1 zu " ; Test(2)                                    'Zählerstand ausgeben


Loop

End
MfG
Stromi