Abl-electronic PIC Microcontrollers PIC16 Bedienungsanleitung Seite 247

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 312
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 246
MikroElektronika:
Development
tools
-
Books
-
Compilers
239
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Library Example
This simple example reads values of keys pressed on PS/2 keyboard and sends them via USART.
unsigned short keydata, special, down;
void main() {
CMCON = 0x07;
// Disable analog comparators (comment this for PIC18)
INTCON = 0;
// Disable all interrupts
Ps2_Init(&PORTA);
// Init PS/2 Keyboard on PORTA
Delay_ms(100);
// Wait for keyboard to finish
do {
if (Ps2_Key_Read(&keydata, &special, &down)) {
if (down && (keydata == 16)) {
// Backspace
// ...do something with a backspace...
}
else if (down && (keydata == 13)) {
// Enter
Usart_Write(13);
}
else if (down && !special && keydata) {
Usart_Write(keydata);
}
}
Delay_ms(10);
// debounce
} while (1);
}
//~!
Seitenansicht 246
1 2 ... 242 243 244 245 246 247 248 249 250 251 252 ... 311 312

Kommentare zu diesen Handbüchern

Keine Kommentare