0 Usuarios y 1 Visitante están viendo este tema.
Codigo:BARRIDO: LOW A IF UNO = 0 THEN lcdout $FE,$C0," 7" IF DOS = 0 THEN lcdout $FE,$C0," 8" IF TRES = 0 THEN lcdout $FE,$C0," 9" IF CUATRO = 0 THEN lcdout $FE,$C0,"10" HIGH A LOW B IF UNO = 0 THEN lcdout $FE,$C0," 4" IF DOS = 0 THEN lcdout $FE,$C0," 5" IF TRES = 0 THEN lcdout $FE,$C0," 6" IF CUATRO = 0 THEN lcdout $FE,$C0,"11" HIGH B LOW C IF UNO = 0 THEN lcdout $FE,$C0," 1" IF DOS = 0 THEN lcdout $FE,$C0," 2" IF TRES = 0 THEN lcdout $FE,$C0," 3" IF CUATRO = 0 THEN lcdout $FE,$C0,"12" HIGH C LOW D IF UNO = 0 THEN lcdout $FE,$C0,"14" IF DOS = 0 THEN lcdout $FE,$C0," 0" IF TRES = 0 THEN lcdout $FE,$C0,"15" IF CUATRO = 0 THEN lcdout $FE,$C0,"13" HIGH D pause 10 GOTO BARRIDO END
Codigo:getkey: PAUSE 50 "Debounce key-inputgetkeyu:" Wait for all keys up PORTB = 0 " All output-pins low TRISB = $f0 " Bottom 4-pins out, top 4-pins in IF ((PORTB >> 4) != $f) THEN getkeyu"If keys down, loop PAUSE 50 " Debounce key-inputgetkeyp:" Wait for keypress FOR row = 0 TO 3 " 4 rows in keypad PORTB = 0 " All output-pins low TRISB = (DCD row) ^ $ff " Set one row pin to output col = PORTB >> 4 " Read columns IF col != $f THEN gotkey" If any keydown, exit NEXT row GOTO getkeyp " No keys down, go look againgotkey: " Change row and column to key number 1 - 16 key = (row * 4) + (NCD (col ^ $f)) "NOTE: for 12-key keypad, change to key = (row * 3) RETURN " Subroutine over END