//变量的基本操作 (在Blink基础上的继续学习)
int ontime =2000;//定义一个变量进行延时时间的统一改变
int offtime=2000;
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);//定义13引脚为输出
}
void loop() {
// put your main code here, to run repeatedly:
ontime = ontime + 1000; //每执行一轮将点亮时间加一秒
offtime = offtime - 1000;//
digitalWrite(13, HIGH); // 芯片输出写出为高点亮LED
delay(1000); // 延时一秒,即等待一千毫秒,括号里可改变数值以变化
delay(ontime);
digitalWrite(13, LOW); // 芯片输出写出为低电平熄灭LED
delay(offtime);
delay(1000); //
}
//int是整型变量,变量有作用域,在函数体内建立的就只有在这个函数里用,是局部变量
//只有在函数体外建立就是全局变量,此项目内所有函数都可使用
//资料可查ttp://www.taichi-maker.com/homepage/reference-index/arduino-code-reference
//关于函数,后面要加括号,括号中有几个东西也要记住,如delay()括号中只有一个东西,
//毫秒为单位,而digitalWrite(13, HIGH);括号中有两个东西,
写代码时最好用英文输入方式,只有打了注释符号后再切换为中文输入