查看: 214|回复: 15

[未解决] 菜鸟小白。求个简单码。。自己研究不出来了。

[复制链接]
  • TA的每日心情
    郁闷
    2020-7-30 10:55
  • 签到天数: 1 天

    [LV.1]初来乍到

    发表于 2020-8-1 13:51 | 显示全部楼层 |阅读模式
    13号引脚,亮60秒然后熄灭10分钟,然后在点亮60秒在熄灭10分钟。无限循环。
    真是那句话。。。给我娘们都不知道从哪下手了,。求码。。。
  • TA的每日心情
    无聊
    2020-8-1 21:53
  • 签到天数: 11 天

    [LV.3]偶尔看看II

    发表于 2020-8-1 14:11 | 显示全部楼层
    这也太简单了吧,用delay
  • TA的每日心情
    无聊
    2020-8-1 21:53
  • 签到天数: 11 天

    [LV.3]偶尔看看II

    发表于 2020-8-1 14:11 | 显示全部楼层
    /*
      Blink
      Turns on an LED on for one second, then off for one second, repeatedly.

      Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
      it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
      the correct LED pin independent of which board is used.
      If you want to know what pin the on-board LED is connected to on your Arduino model, check
      the Technical Specs of your board  at https://www.arduino.cc/en/Main/Products
      
      This example code is in the public domain.

      modified 8 May 2014
      by Scott Fitzgerald
      
      modified 2 Sep 2016
      by Arturo Guadalupi
      
      modified 8 Sep 2016
      by Colby Newman
    */


    // the setup function runs once when you press reset or power the board
    void setup() {
      // initialize digital pin LED_BUILTIN as an output.
      pinMode(13, OUTPUT);
    }

    // the loop function runs over and over again forever
    void loop() {
      digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
      for(int i=0;i<60;i++)
      delay(1000);                       // wait for a second
      digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
      for(int i=0;i<600;i++)
      delay(1000);                       // wait for a second
    }
  • TA的每日心情
    无聊
    2020-8-14 14:32
  • 签到天数: 20 天

    [LV.4]偶尔看看III

    发表于 2020-8-1 14:21 | 显示全部楼层
    delay(x)的作用是停止程序x ms,参数类型是unsigned long,所以直接delay就完事了
  • TA的每日心情
    无聊
    2020-8-14 14:32
  • 签到天数: 20 天

    [LV.4]偶尔看看III

    发表于 2020-8-1 14:23 | 显示全部楼层
    13号引脚,亮60秒然后熄灭10分钟,然后在点亮60秒在熄灭10分钟。无限循环
    1. void setup()
    2. {
    3. pinMode(13,OUTPUT);
    4. }
    5. void loop()
    6. {
    7. digitalWrite(13,HIGH);
    8. delay(60000);
    9. digitalWrite(13,LOW);
    10. delay(600000);
    11. }
    复制代码


  • TA的每日心情
    郁闷
    2020-7-30 10:55
  • 签到天数: 1 天

    [LV.1]初来乍到

     楼主| 发表于 2020-8-1 14:29 | 显示全部楼层
    XlinliY.Zhang 发表于 2020-8-1 14:23
    13号引脚,亮60秒然后熄灭10分钟,然后在点亮60秒在熄灭10分钟。无限循环

    ...

    不需要millis呀////难道是我想多了啊。。
  • TA的每日心情
    郁闷
    2020-7-30 10:55
  • 签到天数: 1 天

    [LV.1]初来乍到

     楼主| 发表于 2020-8-1 14:31 | 显示全部楼层
    sangshu 发表于 2020-8-1 14:11
    /*
      Blink
      Turns on an LED on for one second, then off for one second, repeatedly.

    谢谢大神。。拿走研究去啦。。
  • TA的每日心情
    无聊
    2020-8-14 14:32
  • 签到天数: 20 天

    [LV.4]偶尔看看III

    发表于 2020-8-1 14:32 | 显示全部楼层
    gonet 发表于 2020-8-1 14:29
    不需要millis呀////难道是我想多了啊。。

    小白就老老实实delay了
  • TA的每日心情
    无聊
    2020-8-1 21:53
  • 签到天数: 11 天

    [LV.3]偶尔看看II

    发表于 2020-8-1 16:02 | 显示全部楼层
    本帖最后由 sangshu 于 2020-8-1 16:33 编辑

    /*
      Blink
      Turns on an LED on for one second, then off for one second, repeatedly.

      Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
      it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
      the correct LED pin independent of which board is used.
      If you want to know what pin the on-board LED is connected to on your Arduino model, check
      the Technical Specs of your board  at https://www.arduino.cc/en/Main/Products
      
      This example code is in the public domain.

      modified 8 May 2014
      by Scott Fitzgerald
      
      modified 2 Sep 2016
      by Arturo Guadalupi
      
      modified 8 Sep 2016
      by Colby Newman
    */
    unsigned long realyonemin = 60000;
    unsigned long realyotenmin = 600000;
    unsigned long lastsmillis1 = 0;
    unsigned long lastsmillis10 = 0;
    int state=0;
    int fnstate=0;
    int oness=0;
    // the setup function runs once when you press reset or power the board
    void setup() {
      // initialize digital pin LED_BUILTIN as an output.
      pinMode(13, OUTPUT);
    }

    // the loop function runs over and over again forever
    void loop() {
      
      if (state==fnstate){
       digitalWrite(13, HIGH);
       fnstate=1;
       oness=0;   lastsmillis1=millis();   }
       
       if ((millis() - lastsmillis1) > realyonemin) {
       
        if(state==oness){
      digitalWrite(13, LOW);   // turn the LED on (HIGH is the voltage level)
      oness=1;  lastsmillis10=millis();    }
       }
        if ((millis() - lastsmillis10) > realytenmin) {
          
          fnstate=0;
          
        }
      
      
       }




  • TA的每日心情
    无聊
    2020-8-1 21:53
  • 签到天数: 11 天

    [LV.3]偶尔看看II

    发表于 2020-8-1 16:52 | 显示全部楼层
    /*
      Blink
      Turns on an LED on for one second, then off for one second, repeatedly.

      Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
      it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
      the correct LED pin independent of which board is used.
      If you want to know what pin the on-board LED is connected to on your Arduino model, check
      the Technical Specs of your board  at https://www.arduino.cc/en/Main/Products
      
      This example code is in the public domain.

      modified 8 May 2014
      by Scott Fitzgerald
      
      modified 2 Sep 2016
      by Arturo Guadalupi
      
      modified 8 Sep 2016
      by Colby Newman
    */
    unsigned long realyonemin = 60000;
    unsigned long realytenmin = 600000;
    unsigned long lastsmillis1 = 0;
    unsigned long lastsmillis10 = 0;
    int state=1;
    //int fnstate=0;
    int oness=1;
    // the setup function runs once when you press reset or power the board
    void setup() {
      // initialize digital pin LED_BUILTIN as an output.
      pinMode(13, OUTPUT);
    }

    // the loop function runs over and over again forever
    void loop() {
      
      if (state){
       digitalWrite(13, HIGH);
       state=!state;
       oness=1;
       lastsmillis1=millis();
       }
       
       if ((millis() - lastsmillis1) > realyonemin) {
        //lastsmillis1=millis();
       // if(!state&&oness){
       if(oness){
      digitalWrite(13, LOW);   // turn the LED on (HIGH is the voltage level)
      oness=0;
      lastsmillis10=millis();
        }
       }
        if ((millis() - lastsmillis10) > realytenmin) {
          //lastsmillis10=millis();
          state=!state;
          
        }
      
      
       }
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    热门推荐

    5分钟带你快速了解新一代开发板:M5STACK
    5分钟带你快速了解新一代
    一、什么是M5Stack M5Stack是一种模块化、可堆叠扩展的开发板,每个模块
    Arduino UNO中文数据手册
    Arduino UNO中文数据手册
    2018.9.23重新翻译整理 转载请注明来自Arduino中文社区,并附本帖链接 本帖地址:http
    LabVIEW监控温度传感器
    LabVIEW监控温度传感器
    这里涉及 dht11 数字温度湿度传感器模块、TM1637数码显示模块、LabVIEW。 功能
    黑乌鸦的Arduino兵器库-----DS1302时钟模块
    黑乌鸦的Arduino兵器库---
    嗯 这是一个系列后期会罗列几乎所有的常见基础模块的demo所以 大家的回复将是我最大
    中文 字库 的8针 OLED 12864模块 arduino
    中文 字库 的8针 OLED 128
    屏幕电路SPI连线: 中文字库OLED Arduino UNO GND GND
    Copyright   ©2015-2016  Arduino中文社区  Powered by©Discuz!   
    快速回复 返回顶部 返回列表