Advertisement
eriasu

Protocolo sony Basic

Oct 20th, 2011
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DEFINE OSC 4 'Velocidad de 4 mhz '
  2.  
  3. TRISA = %00000100 'Configuracion de las entradas y salidas del puerto a'
  4. TRISB = %00000000 'Configuracion de las entradas y saldias del puerto b'
  5. nPaq VAR WORD     'Contiene los 12bits con las info de control remoto'
  6. nPWM VAR WORD     'Sirve para leer el pulso'
  7. nBot VAR WORD     'Guardamos solo el numero del boton del control remoto'
  8. nPul VAR WORD     'Sirve para leer el pulso'
  9. nPaq = 0
  10. nPWM = 0
  11. nBot = 0
  12. nPos = 0
  13. nPul = 0
  14.  
  15. e_go:
  16.     GOSUB SONY_IR
  17.     nBot = nPaq & %01111111 'Nos interesa solo el codigo del boton'
  18.     PORTB=nBot
  19.     IF nBot !=0 THEN
  20.         PAUSE 500
  21.         nBot = 0
  22.         nPaq =0
  23.     ENDIF
  24.     TOGGLE PORTA.3
  25.     GOTO e_go
  26.     END
  27. SONY_IR:
  28.     PULSIN PORTA.2,0,nPWM
  29.     TOGGLE PORTA.4
  30.     IF nPWM > 200 THEN
  31.         IF nPWM < 270 THEN
  32.             FOR nPos = 0 TO 11
  33.                 PULSIN PORTA.2,0,nPul
  34.                 IF nPul >= 90 THEN
  35.                     nPaq.0[nPos]=1
  36.                 ELSE
  37.                     nPaq.0[nPos]=0
  38.                 ENDIF
  39.                 NEXT
  40.         ENDIF
  41.     ENDIF
  42.     RETURN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement