在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

如何創建一個Arduino控制的廚房計時器

454398 ? 來源:工程師吳畏 ? 2019-08-05 10:39 ? 次閱讀

廚房定時器用戶界面流程

打開電源后,設備將顯示“Arduino Kitchen Timer”消息3秒鐘。

然后計時器將提示您設置時間。您可以通過按左右鍵將光標移動到分鐘和小時。

您可以使用向上和向下箭頭鍵調整分鐘和小時設置。

設置了所需的時間后,按下選擇按鈕,計時器將啟動。

如果您想再次設置時間,請再次按下選擇按鈕。

一旦時間結束,蜂鳴器將發出蜂鳴聲。

要停止蜂鳴器,請按鍵盤護罩上的重置按鈕。

廚房定時器所需的組件

Arduino

LCD鍵盤護盾

蜂鳴器

廚房定時器的電路圖

首先,對齊并放置L CD Keypad直接屏蔽Arduino。然后將蜂鳴器的正極連接到Arduino上的引腳12,將蜂鳴器的負極連接到地面。

Arduino廚房定時器項目代碼

將以下代碼復制并上傳到Arduino IDE中。代碼的每個部分都有一個附帶的解釋,以幫助您了解它的功能。

#include

// select the pins used for the LCD keypad

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// define some variables

int lcd_key = 0;

int adc_key_in = 0;

int hrs = 0;

int mins = 0;

int set_mins = 0;

int set_hrs = 1;

int secs = 60;

int cursor_pos = 1;

int buzzer_pin = 12;

bool startTimer = false;

bool setTimer = true;

bool get_time = false;

unsigned long interval=1000; // the time we need to wait

unsigned long previousMillis=0; // millis() returns an unsigned long.

// Defining button used by the lcd keypad

#define btnRIGHT 0

#define btnUP 1

#define btnDOWN 2

#define btnLEFT 3

#define btnSELECT 4

#define btnNONE 5

// read the buttons

int read_LCD_buttons()

{

adc_key_in = analogRead(0); // reading the button value from the lcd keypad

// checking which button is pressed

if (adc_key_in 》 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result

if (adc_key_in 《 50) return btnRIGHT;

if (adc_key_in 《 250) return btnUP;

if (adc_key_in 《 450) return btnDOWN;

if (adc_key_in 《 650) return btnLEFT;

if (adc_key_in 《 850) return btnSELECT;

return btnNONE; // when all others fail, return this.。.

}

void setup()

{

Serial.begin(115200);

pinMode(buzzer_pin, OUTPUT);

lcd.begin(16, 2); // start communication with LCD keypad shield

lcd.setCursor(0,0);

lcd.print(“Arduino Kitchen”);

lcd.setCursor(0, 1);

lcd.print(“ Timer”);

delay(3000);

}

void loop(){

// Checking which condition is true based on the button pressed

if(startTimer == true){

start_timer();

}

else if (setTimer == true){

set_timer();

}

}

// This function will count the time and will beep the buzzer when the time will be up.

void start_timer(){

// Checking whether time is up or not

if(hrs == 0 && mins == 0 && secs == 0){

lcd.setCursor(0, 0);

lcd.print(“ Time is UP”);

lcd.setCursor(0, 1);

lcd.print(“ Beep Beep”);

digitalWrite(buzzer_pin, HIGH);

delay(500);

digitalWrite(buzzer_pin, LOW);

delay(500);

}

else if(secs 《 0){

secs = 59;

mins = mins - 1;

}

else if(mins 《 0){

mins = 59;

hrs = hrs - 1;

}

else

{

get_time = true;

counter();

lcd.setCursor(0, 0);

lcd.print(“Timer is ON”);

lcd.setCursor(0, 1);

lcd.print(hrs);

lcd.print(“:”);

lcd.setCursor(4, 1);

lcd.print(mins);

lcd.print(“:”);

lcd.setCursor(8, 1);

lcd.print(secs);

}

lcd_key = read_LCD_buttons(); // read the buttons

switch (lcd_key) // depending on which button was pushed, we perform an action

{

// if select button is pressed, move back to set time

case btnSELECT:

{

startTimer = false;

setTimer = true;

delay(300);

lcd.clear();

break;

}

case btnNONE:

{

break;

}

}

}

// This function will set the time

void set_timer(){

counter();

lcd.setCursor(0, 0);

lcd.print(“Set Time”);

lcd.setCursor(0, 1);

lcd.print(“Hrs:”);

lcd.print(hrs);

lcd.setCursor(8, 1);

lcd.print(“Mins:”);

lcd.print(mins);

lcd.setCursor(0,1);

lcd_key = read_LCD_buttons(); // read the buttons

switch (lcd_key) // depending on which button was pushed, we perform an action

{

// if right button is pressed, then move the cursor to minutes

case btnRIGHT:

{

cursor_pos = set_mins;

break;

}

// if left button is pressed, then move the cursor to hours

case btnLEFT:

{

cursor_pos = set_hrs;

break;

}

// if up button is pressed, add 1 to the minutes or hours

case btnUP:

{

delay(300);

if(cursor_pos == set_mins){

mins++;

if(mins 》 59){

mins = 0;

}

}

else if(cursor_pos == set_hrs){

hrs++;

if(hrs 》 24){

hrs = 0;

}

}

break;

}

// if down button is pressed, minus 1 from the minutes or hours

case btnDOWN:

{

delay(300);

if(cursor_pos == set_mins){

mins--;

if(mins 《 0){

mins = 60;

}

}

else if(cursor_pos == set_hrs){

hrs--;

if(hrs 《 0){

hrs = 24;

}

}

break;

}

// if select button is pressed, start the timer

case btnSELECT:

{

startTimer = true;

setTimer = false;

mins = mins - 1;

delay(300);

break;

}

case btnNONE:

{

break;

}

}

}

void counter() {

unsigned long currentMillis = millis(); // grab current time

// check if “interval” time has passed (1000 milliseconds)

if ((unsigned long)(currentMillis - previousMillis) 》= interval) {

lcd.clear();

if(get_time == true){

secs--;

get_time = false;

}

previousMillis = millis();

}

}

創建廚房計時器只是一個開始!

您已經創建了自己的廚房計時器!該項目的最佳部分是能夠調整該模塊以構建其他項目,這些項目需要LCD和按鈕或蜂鳴器之間的簡單接口。您還可以為模塊設計自定義3D打印的外殼,并使其成為您自己的。

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 計時器
    +關注

    關注

    1

    文章

    426

    瀏覽量

    32959
  • Arduino
    +關注

    關注

    188

    文章

    6478

    瀏覽量

    188295
收藏 人收藏

    評論

    相關推薦

    EE-109:ADSP2106x:使用2106x SPORT作為計時器

    電子發燒友網站提供《EE-109:ADSP2106x:使用2106x SPORT作為計時器.pdf》資料免費下載
    發表于 01-07 14:11 ?0次下載
    EE-109:ADSP2106x:使用2106x SPORT作為<b class='flag-5'>計時器</b>

    單個 MSP430? 計時器模塊的多時基應用說明

    電子發燒友網站提供《單個 MSP430? 計時器模塊的多時基應用說明.pdf》資料免費下載
    發表于 09-13 11:09 ?0次下載
    單個 MSP430? <b class='flag-5'>計時器</b>模塊的多時基應用說明

    MSPM0-高級控制計時器有助于實現更好的控制和更好的數字輸出

    電子發燒友網站提供《MSPM0-高級控制計時器有助于實現更好的控制和更好的數字輸出.pdf》資料免費下載
    發表于 08-28 11:30 ?0次下載
    MSPM0-高級<b class='flag-5'>控制</b><b class='flag-5'>計時器</b>有助于實現更好的<b class='flag-5'>控制</b>和更好的數字輸出

    用于電源門控的TPL5110毫微功耗系統計時器數據表

    電子發燒友網站提供《用于電源門控的TPL5110毫微功耗系統計時器數據表.pdf》資料免費下載
    發表于 08-23 11:26 ?0次下載
    用于電源門控的TPL5110毫微功耗系統<b class='flag-5'>計時器</b>數據表

    用于電源門控應用的TPL5111毫微功耗系統計時器數據表

    電子發燒友網站提供《用于電源門控應用的TPL5111毫微功耗系統計時器數據表.pdf》資料免費下載
    發表于 08-23 11:25 ?0次下載
    用于電源門控應用的TPL5111毫微功耗系統<b class='flag-5'>計時器</b>數據表

    TLC555-Q1 LinCMOS?計時器數據表

    電子發燒友網站提供《TLC555-Q1 LinCMOS?計時器數據表.pdf》資料免費下載
    發表于 08-23 11:19 ?0次下載
    TLC555-Q1 LinCMOS?<b class='flag-5'>計時器</b>數據表

    TLC555 LinCMOS?技術計時器數據表

    電子發燒友網站提供《TLC555 LinCMOS?技術計時器數據表.pdf》資料免費下載
    發表于 08-20 11:15 ?0次下載
    TLC555 LinCMOS?技術<b class='flag-5'>計時器</b>數據表

    LMC555 CMOS計時器數據表

    電子發燒友網站提供《LMC555 CMOS計時器數據表.pdf》資料免費下載
    發表于 08-20 09:16 ?0次下載
    LMC555 CMOS<b class='flag-5'>計時器</b>數據表

    spi_flash期間的計時器中斷導致崩潰怎么解決?

    這是我遇到的 SDK 中的小錯誤 (esp_iot_sdk_v0.9.5_b1): 我在 Timer1 上使用計時器中斷: ets_frc_timer1_intr_attach
    發表于 07-12 11:54

    在esp8266中構建了HTTP服務,功處理HTTP請求后,軟件計時器停止了,為什么?

    定時回調中創建的任務中的連接工作,都失敗了。我在HTTP處理后設置了新的軟件計時器,也失敗了...... 在處理HTTP請求的任務中,
    發表于 07-10 06:15

    TLE986x如何定期重新啟動計時器

    我在模式 0-13 位定時模式下運行 T3。 達到溢出時,計時器停止。 請問如何定期重新啟動計時器
    發表于 07-03 07:13

    雙路精密計時器選購指南:準確選擇,高效工作

    在快節奏的現代生活中,準確的時間管理對于個人和團隊的成功至關重要。雙路精密計時器作為種高效的計時工具,受到了越來越多人的青睞。那么,如何選購款適合自己的雙路精密
    的頭像 發表于 06-26 16:06 ?446次閱讀

    SNx5DPHY440SS CSI-2/DSI DPHY 重計時器數據表

    電子發燒友網站提供《SNx5DPHY440SS CSI-2/DSI DPHY 重計時器數據表.pdf》資料免費下載
    發表于 06-25 11:07 ?1次下載
    SNx5DPHY440SS CSI-2/DSI DPHY 重<b class='flag-5'>計時器</b>數據表

    帶看門狗計時器的TPS382x電壓監視數據表

    電子發燒友網站提供《帶看門狗計時器的TPS382x電壓監視數據表.pdf》資料免費下載
    發表于 03-25 09:52 ?0次下載
    帶看門狗<b class='flag-5'>計時器</b>的TPS382x電壓監視<b class='flag-5'>器</b>數據表

    具有使能功能的 TPS3431 標準可編程監視計時器數據表

    電子發燒友網站提供《具有使能功能的 TPS3431 標準可編程監視計時器數據表.pdf》資料免費下載
    發表于 03-13 14:31 ?0次下載
    具有使能功能的 TPS3431 標準可編程監視<b class='flag-5'>器</b><b class='flag-5'>計時器</b>數據表
    主站蜘蛛池模板: 手机在线亚洲 | 永久免费在线观看 | 色佬网 | 男女一进一出无遮挡黄 | 欧美成人午夜片一一在线观看 | 亚洲v在线| 欧美黄视频在线观看 | 午夜视频免费在线 | 国产理论 | 色宅男看片午夜大片免费看 | 一级特黄aaa大片大全 | 婷婷成人丁香五月综合激情 | 特黄特色的大片观看免费视频 | 日本一区二区三区四区不卡 | 女bbbbxxxx毛片视频 | caobi在线观看| www.色天使 | 毛片2016免费视频 | 六月综合网 | 边摸边吃奶边做视频叫床韩剧 | 亚洲经典乱码在线播 | 国模在线 | 亚洲欧美日韩综合一区 | 黄色视屏在线免费观看 | 又长又大又粗又硬3p免费视频 | 欧美成人午夜不卡在线视频 | 激情 婷婷 | 91av免费在线观看 | 日韩欧美一区二区三区视频 | 永久视频在线观看 | 欧美成人性色生活片天天看 | 免费看黄的视频软件 | 天堂8在线官网 | 五月婷婷精品 | 午夜高清在线 | 五月婷婷六月丁香综合 | 久久51| 黄在线观看网站 | 日本免费一区二区在线观看 | 成人欧美一区二区三区黑人3p | 特色毛片 |