我的Arduino 1分钟后停止等待 [英] My Arduino stops after 1 minute wait

查看:1148
本文介绍了我的Arduino 1分钟后停止等待的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的Arduino编程第一循环结束后,简单地停止。我可能会忽略的东西......但我只是茫然不知发生了什么。

I do have a small Arduino programming that simply stops after first loop. I might overlook something...but I'm simply clueless about what is happening.

下面是code

int led = 13;
//int led = 10;
unsigned long windtime = 1000 * 2; // 2 seconds
unsigned long pausetime = 1000 * 60; // 1 minute

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);

  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  Serial.print("Wind");
  digitalWrite(led, HIGH);
  delay(windtime);               

  Serial.print("Pause");
  digitalWrite(led, LOW);    
  delay(pausetime);
}

我用串口仅作为调试回声。

I used Serial only as debug echo.

任何想法?

推荐答案

看来你需要明确设置数字文字长(L),他们使用它们。否则,这是行不通的。如果任何人都可以解释,如果有任何一种自动的转换将是真棒但直到然后只需使用:

It seems that you need to explicitly set numeric literals to long (L) and they use them. Otherwise it does not work. If anyone can explain if there is any kind of automatic conversion it will be awesome but until then simply use:

unsigned long seconds = 1000L; // !!! SEE THE CAPITAL "L" USED!!!
unsigned long minutes = seconds * 60;
unsigned long hours = minutes * 60; 

,然后简单地使用延迟(毫秒)像往常一样:

and then simply use delay(millisec) as usual:

delay(5 * minutes);

这为我工作。

这篇关于我的Arduino 1分钟后停止等待的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆