i2c to keyboard interface


I2C to Keyboard interface
Here follows a short description on how to use my i2c_kbd library, with this you could use
any AVR circuit with a matrix keyboard with minimal extra hardware. The interface from the
i2c to keyboard consists of a PCF8574 8bit I/O module, so with only 2 pins you could
interface the keyboard (or 3 pins if you use interrupt).
What you need to add in the beginning of your program is the following:
$lib "Key_i2c.lib"
$external _key_scan
Const Pcf8574_lcd = &H42
Config Scl = Portd.6
Config Sda = Portd.7
Dim _key_scan As Byte
!rcall _Key_init
.
.
.
!rcall _Key_Scan
if _key_scan = ? then &
If using interrupts add the following (skip last section from above):
Enable Interrupts
Config Int0 = Falling
On Int0 _int0_label
Enable Int0
.
.
.
if _key_scan = ? then &
.
.
.
_int0_label:
!rcall _Key_Scan
Return
The PCF8574 is connected as follows:
PCF8574
+5V A0 VDD +5V
Hex adress 42 A1 SDA AVR- PortD.7
Gnd A2 SCL AVR- PortD.6
P0 INT AVR- INT0 (optional)
P1 P7
P2 P6
P3 P5
Gnd VSS P4
C1 C2 C3 C4
A0, A1 and A2 gives the address
R1
of the chip
A0 A1 A2 Pcf8574_lcd
0 0 0 &H40
R2
1 0 0 &H42
0 1 0 &H44
R3
1 1 0 &H46
0 0 1 &H48
1 0 1 &H4A
R4
0 1 1 &H4C
1 1 1 &H4E
To observe when using interrupts!
Disable int0 before doing anything time consuming (RS232, LCD etc.) otherwise you may get
problem with those routines, when you press a key the program will jump to _key_scan.
The variable _key_scan holds the value of the key pressed (0 if none)
C1 C2 C3 C4
R1 1 2 3 4
R2 5 6 7 8
R3 9 10 11 12
R4 13 14 15 16


Wyszukiwarka

Podobne podstrony:
i2c to lcd interface
Interfejs I2C, część 2
representing interfaces to external systems?6D84D3
Interfejs I2C, część 1
To ostatnia niedziela keyboard
Podwójny wyświetlacz LED z interfejsem I2C 3
Układ pozycjonowania serwomechanizmu z interfejsem I2C
I2C Interface fuer Druckerschnittstelle
Moduły wyświetlaczy LED z interfejsem I2C 2
2008 03 Making Music Connecting a Midi Keyboard to Your Linux System
Programator pamięci EEPROM z interfejsem szeregowym I2C
Interfejs I2C, część 3
Mikrokontrolery STM32 Użycie interfejsu I2C, USART, SPI
karta przekaźnikowa z interfejsem i2c
Moduł wyświetlacza LED z interfejsem I2C
design user interface?ABE09F
To dzięki wam Preludium

więcej podobnych podstron