N
neillsun
Guest
Sono tirando i capelli con questo ...
Ho una matrice 4x4 ketpad collegato al pin RC0 attraverso RC7 (RC0-RC3 sono colonne e RC4 attraverso RC7 sono righe).
Ho collegato RC4-7 a terra attraverso 10k resistenze, e sto utilizzando il seguente codice (PICCLite in MPLAB IDE), che ho avuto da http://www.rs232pro.com/keypad_hardware.htm, ho copiato il circuito di base, ma io confido in internat OSC, per cui non ho aggiunto il quarzo:
Codice:
# include <pic.h>
# include "delay.h"# define INPUT 1
# define OUTPUT 0void main ()
(const char unsigned tastiera [] = (0x11, 0x21, 0x41, 0x81, 0x12, 0x22, 0x42, 0x82, 0x14, 0x24, 0x44, 0x84, 0x18, 0x28, 0x48, 0x88);
const unsigned char caratteri [] = ('1 ', '2', '3 ',' A ', '4', '5 ', '6', 'B', '7 ', '8', '9 ',' C','*',' 0','#',' D ');
unsigned char, ii;TRISA3 = output;
TRISC = 0xFF;
PORTC = 0xF0;RA3 = 1;while (1)
(
PORTC = 0x0F; / * init / re-port init * /
while (PORTC == 0x0F); / * attesa premere il tasto * /
DelayUs (10);
if (PORTC! = 0x0F)
(
for (i = 0; i <4; i )
(
PORTC = 1 <<i;
for (ii = 0; ii <16; ii )
(
if (PORTC == tastiera [II])
(
RA3 = 0; / * LED * /
DelayUs (200);
DelayUs (200);
RA3 = 1;
i = 4;
break;
)
)
)
)
)
)
Ho una matrice 4x4 ketpad collegato al pin RC0 attraverso RC7 (RC0-RC3 sono colonne e RC4 attraverso RC7 sono righe).
Ho collegato RC4-7 a terra attraverso 10k resistenze, e sto utilizzando il seguente codice (PICCLite in MPLAB IDE), che ho avuto da http://www.rs232pro.com/keypad_hardware.htm, ho copiato il circuito di base, ma io confido in internat OSC, per cui non ho aggiunto il quarzo:
Codice:
# include <pic.h>
# include "delay.h"# define INPUT 1
# define OUTPUT 0void main ()
(const char unsigned tastiera [] = (0x11, 0x21, 0x41, 0x81, 0x12, 0x22, 0x42, 0x82, 0x14, 0x24, 0x44, 0x84, 0x18, 0x28, 0x48, 0x88);
const unsigned char caratteri [] = ('1 ', '2', '3 ',' A ', '4', '5 ', '6', 'B', '7 ', '8', '9 ',' C','*',' 0','#',' D ');
unsigned char, ii;TRISA3 = output;
TRISC = 0xFF;
PORTC = 0xF0;RA3 = 1;while (1)
(
PORTC = 0x0F; / * init / re-port init * /
while (PORTC == 0x0F); / * attesa premere il tasto * /
DelayUs (10);
if (PORTC! = 0x0F)
(
for (i = 0; i <4; i )
(
PORTC = 1 <<i;
for (ii = 0; ii <16; ii )
(
if (PORTC == tastiera [II])
(
RA3 = 0; / * LED * /
DelayUs (200);
DelayUs (200);
RA3 = 1;
i = 4;
break;
)
)
)
)
)
)