亚洲春色中文字幕久久久-三上亚,一吻二脱三床四吻胸,国产真实伦对白视频全集,在线毛片观看,精品成品入口黄网,国产毛aⅴ片久久久,亚洲AV色香蕉一区二区三区老师,萧皇后A级艳片,色情日本视频更新,99久久亚洲精品日本无码

標(biāo)題: 一個(gè)簡(jiǎn)單的51單片機(jī)與鍵盤(pán)通訊的測(cè)試小程序 [打印本頁(yè)]

作者: oldspring    時(shí)間: 2018-12-4 14:44
標(biāo)題: 一個(gè)簡(jiǎn)單的51單片機(jī)與鍵盤(pán)通訊的測(cè)試小程序
這里介紹一個(gè)簡(jiǎn)單的51單片機(jī)與鍵盤(pán)通訊的測(cè)試小程序,它同樣可以用在 4x1, 4x2 或者 4x3 Keypad 上。希望對(duì)大家有用。(這個(gè)小程序是將鍵盤(pán)上的鍵碼通過(guò)PS2接口,由51單片機(jī)的串行接口輸出,進(jìn)行測(cè)試。)


  1. unsigned short keydata = 0, special = 0, down = 0;

  2. // PS2 module connections
  3. sbit PS2_DATA  at P0_0_bit;
  4. sbit PS2_CLOCK at P0_1_bit;
  5. // End PS2 module connections

  6. void main() {

  7.   UART1_Init(4800);         // Initialize UART module at 4800 bps
  8.   Ps2_Config();             // Initialize PS/2 Keyboard
  9.   Delay_ms(100);            // Wait for keyboard to finish
  10.   
  11.   UART1_Write_Text("Ready");
  12.   UART1_Write(10);          // Line Feed
  13.   UART1_Write(13);          // Carriage return

  14.   do {
  15.     if (Ps2_Key_Read(&keydata, &special, &down)) {
  16.       if (down && (keydata == 16)) {// Backspace
  17.          UART1_Write(0x08);
  18.       }
  19.       else if (down && (keydata == 13)) {// Enter
  20.         UART1_Write('r');               // send carriage return to usart terminal
  21.         //Usart_Write('n');             // uncomment this line if usart terminal also expects line feed
  22.                                          // for new line transition
  23.       }
  24.       else if (down && !special && keydata) {
  25.         UART1_Write(keydata);
  26.       }
  27.     }
  28.     Delay_ms(10);            // debounce
  29.   } while (1);
  30. }
復(fù)制代碼
相關(guān)信息:http://www.denmoz.com/bbs/dpj-136722-1.html









歡迎光臨 (http://www.denmoz.com/bbs/) Powered by Discuz! X3.1