Hi, Queenidog

Don't you know the LOOKUP command exactly does that ??? ( much simpler, no ??? ...)

you also could play with POKECODE and PEEKCODE ... to make things a bit funny ...

Code:

'*****************************************************************************
PwmLoop: ' 165 steps per sec. = ... 3ms per loop
'*****************************************************************************
 
'Short loop 24 > 336 µs
  
IF ( Sampled >= 31 ) then      ' No light if Sampled < 31
 
 Delay2 = 0
 peekcode ( 850 + sampled ), delay  ' 881 = 850 + 31 !!!
 
 IF Sampled >= 87 Then Longloop
 
 IF Sampled >= 79 THEN Delay2 = 1  ' Add 255 to Pauseus...using BYTE
 
 Strob_led = 1
  
 Pauseus delay
 IF Delay2 Then Pauseus 255
      
 Strob_led = 0
       
ENDIF
 delay = 0
  
Longloop:
 
 For x = 0 to 13 ' min 336 µs
 
  IF delay then Strob_led = 1   'Skip min Pauseus ...
   
  Pauseus delay
 
  Strob_led = 0
  
  Pauseus   Duration  - delay
  
 next x
RETURN

....


'*****************************************************************************
'Fading_Table
'*****************************************************************************
'             0   1   2   3   4   5   6   7   8   9  
'
Pokecode @881,       24, 27, 29, 32, 35, 38, 41, 44, 47,_ '  30
             50, 54, 57, 60, 64, 68, 71, 75, 79, 83,_ '  40
             87, 91, 96,100,104,109,113,118,123,127,_ '  50
            132,137,142,147,153,158,163,169,174,180,_ '  60
            186,191,197,203,209,212,217,245,250,  1,_ '  70
              7, 13, 21, 30, 39, 48, 57, 24, 25, 26,_ '  80
             27, 28, 29, 30, 31, 32, 33, 34, 35, 36,_ '  90
             37, 38, 39, 40, 41, 43, 44, 45, 46, 48,_ ' 100
             49, 50, 52, 53, 54, 56, 57, 59, 60, 62,_ ' 110
             63, 65, 67, 68, 70, 72, 73, 75, 77, 79,_ ' 120
             81, 83, 84, 86, 88, 90, 92, 94, 97, 99,_ ' 130
            101,103,105,107,110,112,114,117,119,122,_ ' 140
            124,126,129,132,134,137,139,142,145,148,_ ' 150
            150,153,156,159,162,165,168,172,176,180  ' 160
Alain