代码之家  ›  专栏  ›  技术社区  ›  Richard Forss

Arduino-带液晶屏的多按钮事件

  •  2
  • Richard Forss  · 技术社区  · 15 年前

    谢谢,

    理查德。

    1 回复  |  直到 15 年前
        1
  •  0
  •   Greg Bogumil    15 年前

    我假设你已经知道如何检查按钮是否被按下,并且已经知道当两个按钮都被按下时如何做你想做的事情。

    bool button1Pressed = CheckIfButtonPressed(1);
    bool button2Pressed = CheckIfButtonPressed(2);
    
    if (button1Pressed && button2Pressed)
      DoTheThingYouWantToDoWhenBothButtonsArePressed();
    

    注意:您可能还需要包含一些计时代码,以确保在按下按钮时不会继续做您想做的事情。为此你要在尸体上贴上时间戳 if 语句,还包括 else 取消设置时间戳。