欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 一個簡單的LCD16x2單片機小程序 [打印本頁]

作者: oldspring    時間: 2018-10-14 10:20
標題: 一個簡單的LCD16x2單片機小程序
前幾天,發現了這個51hei網站,突發奇想,向大家推薦了一個51編譯器,雖然得到了黑班主的50黑幣,但是沒有任何51黑弟兄們的捧場,實在遺憾。
今后,我會經常到這里來溜達溜達,推薦一些常見電路簡單編程(諸如 LCD 16x2 or 16x4, LCD 12864, I2C, SPI, SD Card, 等等........) 。希望大家喜歡。
以下是一個簡單的 LCD 16x2 的單片機小程序:
  1. // Lcd module connections
  2. sbit LCD_RS at P2_0_bit;
  3. sbit LCD_EN at P2_1_bit;

  4. sbit LCD_D4 at P2_2_bit;
  5. sbit LCD_D5 at P2_3_bit;
  6. sbit LCD_D6 at P2_4_bit;
  7. sbit LCD_D7 at P2_5_bit;
  8. // End Lcd module connections

  9. char txt1[] = "mikroElektronika";
  10. char txt2[] = "Easy8051B";
  11. char txt3[] = "Lcd4bit";
  12. char txt4[] = "example";

  13. char i;                              // Loop variable

  14. void Move_Delay() {                  // Function used for text moving
  15.   Delay_ms(500);                     // You can change the moving speed here
  16. }

  17. void main(){

  18.   Lcd_Init();                        // Initialize Lcd

  19.   Lcd_Cmd(_LCD_CLEAR);               // Clear display
  20.   Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  21.   Lcd_Out(1,6,txt3);                 // Write text in first row

  22.   Lcd_Out(2,6,txt4);                 // Write text in second row
  23.   Delay_ms(2000);
  24.   Lcd_Cmd(_LCD_CLEAR);               // Clear display

  25.   Lcd_Out(1,1,txt1);                 // Write text in first row
  26.   Lcd_Out(2,5,txt2);                 // Write text in second row

  27.   Delay_ms(2000);

  28.   // Moving text
  29.   for(i=0; i<4; i++) {               // Move text to the right 4 times
  30.     Lcd_Cmd(_LCD_SHIFT_RIGHT);
  31.     Move_Delay();
  32.   }

  33.   while(1) {                         // Endless loop
  34.     for(i=0; i<8; i++) {             // Move text to the left 7 times
  35.       Lcd_Cmd(_LCD_SHIFT_LEFT);
  36.       Move_Delay();
  37.     }

  38.     for(i=0; i<8; i++) {             // Move text to the right 7 times
  39.       Lcd_Cmd(_LCD_SHIFT_RIGHT);
  40.       Move_Delay();
  41.     }
  42.   }
  43. }
復制代碼
附:簡單電路圖。





51-LCD16x2.jpg (41.75 KB, 下載次數: 64)

51-LCD16x2.jpg

作者: songxia8013    時間: 2018-10-14 17:00
這是個什么軟件做的?沒見過這個軟件!
作者: oldspring    時間: 2018-10-15 09:37
http://m.raoushi.com/bbs/dpj-136722-1.html






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