日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

avr计数_使用8位LCD创建计数器| AVR

發布時間:2025/3/11 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 avr计数_使用8位LCD创建计数器| AVR 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

avr計數

This type of counter may be also used in the EVM machines. A counter can be used to count the number of times a button is pressed. It can have many applications. The most widely used counter application is in EVM and also in customer feedback machines.

這種類型的計數器也可以在EVM機器中使用。 計數器可用于計算按下按鈕的次數。 它可以有很多應用。 最廣泛使用的計數器應用程序是在EVM中以及在客戶反饋機中。

CODE

#include <avr/io.h> #define F_CPU 1000000 #include <util/delay.h> #define RS 0 #define EN 1void lcd_comm (char); void lcd_data (char); void lcd_init (void); void lcd_string (char*); void lcd_num (int n);int main(void) {int c = 0;DDRA = 0x00;lcd_init();lcd_comm(0x84);lcd_string("COUNTER");lcd_comm(0xC5);lcd_data(c+48);while(1){if( (PINA & 0x01) == 1 ){c++;lcd_comm(0xC5);lcd_num(c);while( (PINA & 0x01) == 1 );}} }void lcd_comm(char x){PORTD = x;PORTC &= ~(1<<RS);PORTC |= 1<<EN;_delay_ms(5);PORTC &= ~(1<<EN); }void lcd_data(char x){PORTD = x;PORTC |= 1<<RS;PORTC |= 1<<EN;_delay_ms(5);PORTC &= ~(1<<EN); }void lcd_init(void){DDRD = 0xFF;DDRC = 0x03;lcd_comm(0x38);lcd_comm(0x06);lcd_comm(0x0E);lcd_comm(0x01);lcd_comm(0x80); }void lcd_string(char* p){while(*p!='\0'){lcd_data(*p);p++;} }void lcd_num(int n){lcd_data((n/1000)+48);n %= 1000;lcd_data((n/100)+48);n %= 100;lcd_data((n/10)+48);n %= 10;lcd_data(n+48); } .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}}

Explanation:

說明:

  • Firstly we have included all the header file that is required basically

    首先,我們包含了所有基本需要的頭文件

  • At the initial condition, we have defined EN=1 and RS=0.

    在初始條件下,我們定義了EN = 1和RS = 0 。

  • Next we have defined certain functions lcd_comm(char), lcd_data(char) and lcd_init(void) etc.

    接下來,我們定義了某些函數lcd_comm(char) , lcd_data(char)和lcd_init(void)等。

  • Inside the int main(void) we have created a variable c which is an integer and initially it is equal to zero. It will remember the number of times we will press our push button.

    在int main(void)內部,我們創建了一個變量c ,它是一個整數,最初它等于零。 它會記住我們按下按鈕的次數。

  • DDRA=0x00 says that we have connected a push button to PA0.

    DDRA = 0x00表示我們已將按鈕連接到PA0 。

    The

    lcd_init(); will run the lcd_init function that we have defined below.

    lcd_init(); 將運行下面定義的lcd_init函數。

    The command

    命令

    0x84 is made our string(COUNTER) in between of the LCD display

    0x84是我們在液晶顯示器之間的字符串(COUNTER)

    Lcd_string("COUNTER") will print COUNTER.

    Lcd_string(“ COUNTER”)將打印COUNTER。

    Lcd_data(c+48) is used to write our string in ASCII code.

    Lcd_data(c + 48)用于以ASCII代碼寫入我們的字符串。

  • Inside the while loop, we have written our condition if the button is pressed we add 1 to our variable c.

    在while循環內部,如果按下按鈕,我們就寫了條件,我們在變量c中加了1。

  • The command 0xCS will overwrite the initial zero condition of our counter.

    命令0xCS將覆蓋計數器的初始零條件。

  • Inside the void lcd_comm(char x), we have taken the variable as char x, which we have assigned to PORTD. In the next step we have masked the initial value of RS which was initially 0, and here we have made it 1. Next, we have made our Enable Pin high and then low by giving the time delay of 5ms in between.

    在void lcd_comm(char x)內 ,我們將變量指定為char x ,并將其分配給PORTD 。 在下一步中,我們屏蔽了RS的初始值,該值最初為0,在這里我們將其設置為1。接下來,通過在5ms之間設置時間延遲,將使能引腳設為高電平,然后設為低電平。

  • Again for the next function, we would be giving the data to LCD through this. We have taken a variable x, and assigned to PORTD, again made RS pin 0 and also have done similarly the Enable pin high and then low by providing the time delay of 5ms. In this function lcd_init(void), we have written all the commands that are required for the LCD at the beginning. The DDRD=0xFF indicates all the data pins connected to the PORTD, and DDRC=0x03 is for the connection of the ENABLE Pin and R/S pin we connected to PORTC.

    再次為下一個功能,我們將通過此將數據提供給LCD。 我們已將變量x分配給PORTD ,再次將其設為RS引腳0,并且通過提供5ms的時間延遲,同樣將Enable引腳設為高電平,然后設為低電平。 在此函數lcd_init(void)中 ,我們在一開始就編寫了LCD所需的所有命令。 DDRD = 0xFF表示連接到PORTD的所有數據引腳,而DDRC = 0x03用于連接我們連接到PORTC的ENABLE引腳和R / S引腳。

    0x38 - as the LCD is in 8 bit mode.

    0x38 -LCD處于8位模式。

    0x06 - cursor shifts to the right.

    0x06-光標向右移動。

    0x0E - display ON and cursor ON.

    0x0E-顯示打開,光標打開。

    0x01 - clears the screen.

    0x01-清除屏幕。

    Ox80 – 0th row and 0th column.

    Ox80 – 0行和 0列。

  • The function lcd_string(char *p) is used to print the words and are simple strings, here we have used them to print the word COUNTER.

    函數lcd_string(char * p)用于打印單詞,它們是簡單的字符串,這里我們使用它們來打印單詞COUNTER。

  • The void lcd_num(int n) function is used to display n which is equal to the number of times the button is pressed. Inside the function, we have defined three conditions for n to be a three digit number, a two digit number, and a single digit number. We have also used mod here so that we can get the accurate value of n.

    void lcd_num(int n)函數用于顯示n ,該n等于按鈕被按下的次數。 在函數內部,我們為n定義了三個條件,即三個數字,兩個數字和一個數字。 我們在這里還使用了mod,以便獲得n的準確值。

.minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}}

Simulation:

模擬:

Explanation:

說明:

  • Components required:

    所需組件:

  • 1 resistor
  • 2 ground terminal
  • LM016L i.e. our LCD
  • Atmega16
  • Push button
  • Power terminal
  • Make the connections as shown above.

    如上所示進行連接。

  • Double click on power terminal and edit its property to +5V.

    雙擊電源端子,然后將其屬性編輯為+ 5V。

  • Connected the resistor after the push button such that the high unwanted current goes directly ti it.

    在按鈕之后連接電阻,以使多余的高電流直接流過該電阻。

  • Double click the Atmega16 and debug the HEX file.

    雙擊Atmega16并調試HEX文件。

  • Click on the Run Button and your counter will run and the no. if times you will press the button will appear on the screen.

    單擊運行按鈕,您的計數器將運行,并且沒有。 如果您要按幾次,該按鈕將出現在屏幕上。

翻譯自: https://www.includehelp.com/embedded-system/create-counter-using-an-8-bits-lcd-avr.aspx

avr計數

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的avr计数_使用8位LCD创建计数器| AVR的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产激情无码一区二区 | 免费视频毛片 | 国产操比视频 | 亚洲黄色在线看 | 国产在线观看99 | 国产一区二区三区四区三区四 | 玉米地疯狂的吸允她的奶视频 | 91精品国产综合久久福利 | 精品人妻一区二 | 自拍偷拍21p | 国产日批视频在线观看 | 青青草国内自拍 | 亚洲熟妇中文字幕五十中出 | 久久久久成人片免费观看蜜芽 | 久久午夜影院 | 亚洲国产日韩欧美一区二区三区 | av网在线播放 | 男人天堂五月天 | 麻豆视频入口 | 香蕉网久久 | 国产亚洲精品精品精品 | 亚洲一区二区三区四区视频 | 日韩中文字幕网址 | 已满18岁免费观看电视连续剧 | 在线免费看污网站 | 亚洲精品日韩精品 | 免费三片在线观看网站v888 | 侵犯女教师一区二区三区 | 国产另类av| 国语播放老妇呻吟对白 | 黑人粗进入欧美aaaaa | 一区日韩 | 日本免费一区二区三区四区五六区 | 国产99久 | 美女福利视频在线 | aaaaav| 国产午夜久久久 | 亚洲乱码精品久久久久.. | 亚洲成a人片777777久久 | 999视频在线| 乳色吐息在线观看 | 欧美一级网址 | 成长快手短视频在线观看 | 美国一级黄色大片 | 成人午夜影院 | 三级视频在线 | 久久国产精品-国产精品 | 成人影片网址 | 国产成人av一区二区三区不卡 | 亚洲欧美中文日韩在线v日本 | 制服丝袜第一页在线观看 | 久久亚洲色图 | 激情伊人| 黄色小视频入口 | a视频免费观看 | 国产最新精品 | 午夜久久 | 亚洲av无码乱码在线观看性色 | 久草免费看 | 日本免费a级片 | 婷婷日 | 国产精品久久一区二区三区动 | 国产一区二区三区小说 | 黄色av网站在线看 | 中文字幕一区二区在线播放 | 天天视频亚洲 | 一级一片免费播放 | 日韩一卡二卡 | 成人小视频免费看 | 四色成人av永久网址 | 法国少妇愉情理伦片 | 怡春院在线视频 | 丁香六月综合 | 日日鲁鲁鲁夜夜爽爽狠狠视频97 | 国产精品人人做人人爽 | 欧美日韩国产免费 | 日本jizz在线观看 | 精品婷婷色一区二区三区蜜桃 | 国产成人精品免费在线观看 | 911福利视频| 宿舍女女闺蜜调教羞辱 | 欧美视频在线免费看 | 美女福利片| 国产免费一区二区三区在线观看 | 久久综合免费视频 | 中文字幕一区二区三区四区免费看 | 免费视频毛片 | 6080久久 | 日韩精品第1页 | 欧美图片一区 | 青青草亚洲 | 大奶子网站| 国产精品又黄又爽又色无遮挡 | 四虎影视永久免费 | 久久久久久久国产精品视频 | 老头av | 色国产在线 | 中文一区在线观看 | 黄色网www |