“Time.setTime()”的版本间的差异

来自Microduino Wikipedia
跳转至: 导航搜索
(创建页面,内容为“<pre style="color:green"> sensorMotion.begin() </pre> *'''作用''':<br> Sensor_Motion库的初始化函数,可以自动配置Sensor_Motion传感器的串口波...”)
 
第1行: 第1行:
 
<pre style="color:green">
 
<pre style="color:green">
sensorMotion.begin()
+
time.setTime(int hr, int min, int sec, int day, int month, int yr)
  
 
</pre>
 
</pre>
  
 
*'''作用''':<br>
 
*'''作用''':<br>
Sensor_Motion库的初始化函数,可以自动配置Sensor_Motion传感器的串口波特率。
+
按时、分、秒、日、月、年格式设置time库的时间
 
 
  
 
*'''参数''':无<br>
 
*'''参数''':无<br>
 +
hr:小时
 +
min:分钟
 +
sec:秒钟
 +
day:日
 +
month:月
 +
yr:年
  
 
+
*'''例子''':<br>
*'''例子''':这里以硬串口通讯为例<br>
 
 
<pre style="color:green">
 
<pre style="color:green">
#include <Sensor_Motion.h>
+
#include <TimeLib.h>
 
+
Time time;
sensorMotion motion(&Serial1);
 
  
 
void setup(){
 
void setup(){
     motion.begin();
+
     time.setTime(15, 45, 00, 10, 7, 2017);//设置时间(2017年7月10日,15:45:00)
 
}
 
}
  
 
void loop(){
 
void loop(){
 
}
 
}
 
  
 
</pre>
 
</pre>
  
*'''例子''':这里以软串口通讯为例<br>
 
<pre style="color:green">
 
#include <Sensor_Motion.h>
 
 
SoftwareSerial mySerial(2, 3); // RX, TX
 
sensorMotion motion(&mySerial);
 
 
void setup(){
 
    motion.begin();
 
}
 
 
void loop(){
 
}
 
 
 
</pre>
 
  
[[https://wiki.microduino.cn/index.php/Sensor-Motion/zh 返回Sensor_Motion语法手册]]
+
[[https://wiki.microduino.cn/index.php/Data_Time_Reference 返回Data_Time语法手册]]

2017年7月10日 (一) 07:46的版本

time.setTime(int hr, int min, int sec, int day, int month, int yr)

  • 作用:

按时、分、秒、日、月、年格式设置time库的时间

  • 参数:无

hr:小时 min:分钟 sec:秒钟 day:日 month:月 yr:年

  • 例子:
#include <TimeLib.h>
Time time;

void setup(){
    time.setTime(15, 45, 00, 10, 7, 2017);//设置时间(2017年7月10日,15:45:00)
}

void loop(){
}


[返回Data_Time语法手册]