PIC16F877A e un tastierino 4x4

L

Legatus

Guest
Ho una domanda per tutte le menti brillanti del consiglio di amministrazione EDA:

Come si può interfacciare una tastiera 4x4 con un PIC16F877A?

Oh, e sto usando il compilatore CCS.

Grazie

<img src="http://www.edaboard.com/images/smiles/icon_biggrin.gif" alt="Very Happy" border="0" />
 
Provare h ** p: / / w.ccsinfo.com * w / forum / per gli esempi.* Di sostituire il corso.Il principio è lo stesso per la maggior parte Pics, basta cambiare assegnazioni dei pin.

 
L'ho fatto uno per uno con 8.052 Ke * l compilatore.Questo è per la 3x4, ma dà l'idea generale.Devono essere facilmente adattabile per un PIC.

/ / Per saperne di tastiera e restituisce Digit Value

unsigned char GetKey (void) / / Get Keypress
(
sbit C3 = 0xA4; / / P2.4
sbit C2 = 0xA5; / / P2.5
sbit C1 = 0xA6; / / P2.6
sfr P2 = 0xA0; / / Port 2 connessione nibble Bassa

unsigned char Digit, KeyRead;

C1 = 0; C2 = 1; C3 = 1; / / colonna 1, in
KeyRead = (P2 & 0x0F);
if (KeyRead == 14) Cifra = 1; / / Leggi Righe e Traduci
if (KeyRead == 13) Cifra = 4;
if (KeyRead == 11) Cifra = 7;
if (KeyRead == 7) Digit = 10; / / Cancel Key

C1 = 1; C2 = 0; C3 = 1; / / colonna 2
KeyRead = (P2 & 0x0F);
if (KeyRead == 14) Cifra = 2;
if (KeyRead == 13) Cifra = 5;
if (KeyRead == 11) Cifra = 8;
if (KeyRead == 7) Digit = 0;

C1 = 1; C2 = 1; C3 = 0; / / Colonna 3 On
KeyRead = (P2 & 0x0F);
if (KeyRead == 14) Digit = 3;
if (KeyRead == 13) Digit = 6;
if (KeyRead == 11) Cifra = 9;
if (KeyRead == 7) Digit = 11; / / tasto di chiamata

C1 = 0; C2 = 0; C3 = 0;
while ((P2 & 0x0F)! = 0x0F) () / / Waits per la chiave di sblocco
Scandaglio = 0;
return Digit;
)

 
Grazie, mi ha dato * * un'idea.Cercherò di convertirlo in PIC

<img src="http://www.edaboard.com/images/smiles/icon_wink.gif" alt="Wink" border="0" />** <- Modifica

 

Welcome to EDABoard.com

Sponsor

Back
Top