日韩性视频-久久久蜜桃-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的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 国产精品久久久久久久久久直播 | 原来神马电影免费高清完整版动漫 | 亚洲一区二区欧美 | 欧美三级免费 | 欧美一级二级片 | 免费20分钟超爽视频 | 久久久久一 | 欧美日韩成人一区 | 日本香蕉网 | 啪啪网视频 | 99久久精品无码一区二区毛片 | 美女国产在线 | 日韩欧美在线观看视频 | 不卡av网站 | 中文字幕天堂在线 | 国产美女网站视频 | 午夜h | 另类小说一区二区 | 精品人妻一区二区三区久久夜夜嗨 | 九九资源网 | 欧美aaaa视频| 国产不卡毛片 | 国产精选第一页 | 国产欧美一区二区三区在线老狼 | 亚洲欧美一 | 无码人妻精品一区二区三区99日韩 | 亚洲精品一区二区三区蜜桃 | 国产日韩高清在线 | 色噜噜狠狠成人中文 | 国产91在线看 | 国产不卡av在线 | 麻豆视频在线 | 日韩欧美成人一区二区三区 | 免费大片黄在线观看 | 免费黄色片网站 | 无码精品一区二区三区在线播放 | 久久久这里有精品 | 蜜臀一区二区三区精品免费视频 | 成人性生交大片免费看r链接 | www.五月婷婷| 亚洲视频一区二区三区 | 91久久精品无码一区二区 | 日本一区二区三区久久久久 | 久久精品国产99精品国产亚洲性色 | 1级黄色大片儿 | 污动漫网站 | 女人18毛片水真多 | 热播网| 人人干人人玩 | 红桃视频黄色 | 国产做爰全免费的视频软件 | www.亚洲激情| 欧美黄视频 | 久久久不卡国产精品一区二区 | 久久国产精品亚洲 | 激情综合网五月 | a在线观看| 色爽爽一区二区三区 | 玖玖爱在线精品视频 | 午夜少妇久久久久久久久 | 五月天丁香婷 | 日本伦理一区二区三区 | 国产av毛片| 久久综合久久综合久久综合 | 国产女人毛片 | 污视频在线观看免费 | 日本丰满少妇 | 91精品国产乱码久久久张津瑜 | 西方av在线 | 亚洲www啪成人一区二区麻豆 | 免费观看已满十八岁 | 又大又粗弄得我出好多水 | 手机成人av在线 | 久久久久人妻一区 | 骚虎视频在线观看 | 国产日韩欧美精品在线观看 | 视频一区二区在线 | 精品国产aⅴ麻豆 | 特黄特黄视频 | 性久久 | 成人在线视频一区二区三区 | 日韩免费a | 久久久全国免费视频 | www视频在线观看免费 | 男女国产精品 | 国产精品1234 | 日韩精品免费一区二区三区 | av最新| 成人教育av | 亚洲精品日产精品乱码不卡 | av高潮| 久色伊人 | 激情久| 长篇h版少妇沉沦交换 | 精品成人av一区二区在线播放 | 翔田千里x88aⅴ | 黄片毛片一级 | 熟女精品一区二区三区 | 少妇又紧又爽视频 |