zoukankan      html  css  js  c++  java
  • 任务2 按钮控制的LED延时开关效果

    任务2 按钮控制的LED延时开关效果

    程序解读:

    const int ledPin=13;//LED灯连接13数字引脚

    const int keyPin=6;//按键模块连接数字6引脚

    void setup()

    {

     pinMode(keyPin,INPUT);//设置输入模式

     pinMode(ledPin,OUTPUT);//设置输出模式

     }

    void loop()

    {

      int x =digitalRead(keyPin);//设置变量,保存读取的keyPin状态

      if(x==LOW)//if,用于与比较运算符结合使用,测试是否已达到某些条件

      {

        digitalWrite(ledPin,LOW);//如果x低电平,写数字引脚, 对应引脚的低电平

       }

       else//否则跳过

       {

        delay(3000);//延迟效果3秒钟

        digitalWrite(ledPin,HIGH);//如果x高电平,写数字引脚, 对应引脚的高电平     

        }

    开发计算机创智课程的实践研究
  • 相关阅读:
    GIT 相关
    createFile
    值传递、指针传递、引用传递
    Sightseeing trip
    find the longest of the shortest
    Laurenty and Shop
    Dima and Lisa
    Marina and Vasya
    Kolya and Tanya
    Two Substrings
  • 原文地址:https://www.cnblogs.com/ztg1/p/12554782.html
Copyright © 2011-2022 走看看