Arduino 基本设置 + timer
来源:互联网 发布:e站app 显示网络错误 编辑:程序博客网 时间:2024/05/19 17:50
这次的文章目的是从一个Arduino的0基础新人的角度进行timer的编程下载和调试。
感谢Beck的教学~ 第一次感觉arduino还是挺亲切的233
timer library 文件:http://download.csdn.net/detail/u013429988/9836229
或者从github上下载:http://github.com/JChristensen/Timer
1. Arduino IDE 界面:
2.如何下载烧录程序:
(1). 首先要选择和自己的arduino板子一致的
(2). 然后要选择下载用的串口,你可以在tool->port中看到arduino 的IDE 中自动检测到的port 和板子
(3)编译,下载,运行。
烧录的时候右下角会有小进度条 (compiling,uploading):
如何确定程序已经下载完毕,并且已经在运行:
3. 如何给sketch添加公用的library
在安装完 arduino的IDE之后就会在文档中自动生成一个Arduino的文件夹。
把library文件放在这个文件夹下,就让所有的sketch都自动调用这些library文件了。
4. Timer 调用一个完整的Timer 库
在添加好库文件之后,就可以在代码中使用库文件了。
5. 如何监控运行中的变量
在烧录完成之后运行时怎样才能看到打印出来的变量呢?
点击右上角的放大镜标志,如下图所示:
会跳出来一个窗口,里面就是print的数据:
经测试,基本就是一秒加一,没有什么问题。
代码:
//Flash two LEDs at different rates using Simon Monk's Timer library//http://www.doctormonk.com/2012/01/arduino-timer-library.html////Jack Christensen 30Sep2013////Beerware license: Free for any and all purposes, but if you find it//useful AND we actually meet someday, you can buy me a beer!#include "Timer.h" //http://github.com/JChristensen/Timerconst int LED1 = 8; //connect one LED to this pin (with appropriate current-limiting resistor of course)const int LED2 = 9; //connect another LED to this pin (don't forget the resistor)const unsigned long PERIOD1 = 1000; //one secondconst unsigned long PERIOD2 = 10000; //ten secondsTimer t; //instantiate the timer objectint i=0;void setup(void){ Serial.begin(9600); pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); t.oscillate(LED1, PERIOD1, HIGH); t.oscillate(LED2, PERIOD2, HIGH); t.every(1000,callbackfun);//unit:ms,self-writen function.}void loop(void){ t.update();}void callbackfun(void){if(i>100) { i=0; } else { i=i+1; } Serial.println(i); }
完结★,°:.☆( ̄▽ ̄)/$:.°★ 。
0 0
- Arduino 基本设置 + timer
- Arduino(16MHz) timer mechanism
- Arduino 基本语法
- Part3 Arduino基本函数
- Arduino程序基本结构
- ROS系列 Arduino IDE设置
- Arduino:设置ADC参考电压
- Arduino - 看门狗定时器(WDT:Watch Dog Timer)
- Timer的是基本使用方法
- Timer定时器的基本使用
- DSP 之定时器设置(TIMER)
- Arduino Wire.h 库函数基本操作 IIC
- 关于Arduino Mega2560的最基本介绍
- 关于Arduino Mega2560的最基本介绍
- Arduino - ESP8266 Wifi 模块 之 设置
- Arduino
- arduino
- Arduino
- 如何保存Keras模型?
- camel自定义组件
- Linux中java log输出中文乱码 中文变“?”
- Array Partition I,数组分对中最小值的和最大值
- 什么是计量与支付
- Arduino 基本设置 + timer
- javaScript 知识点
- 【贪心】洛谷 P1208 [USACO1.3]混合牛奶 Mixing Milk
- 正则分析法获得url参数
- 利用Spring获得Request和Session
- EasyIndictor 一款简单易用的android导航栏
- c++之静态函数和静态方法
- 刷清橙OJ--A1001.01序列
- easyui 增加统计行