2016年8月28日 星期日
[Arduino]Day-10-Timer1
要記得將TimerOne解壓到Libiary資料夾裡面
基本上,可以從序列埠看到一秒顯示一次
Ardunio只有三個Timer
分別為Timer0,1,2
其中0是8bit,1是16Bit,2是8Bit
////////////////////////////////////////////////
#include <TimerOne.h>
int Timer_count = 0;
void setup()
{
Serial.begin(9600);
Serial.println("Serial ready" ) ;
Timer1.initialize(1000000); // 1000000 = 1sec, set a timer of length 1 sec
Timer1.attachInterrupt( timer_1_Isr ); // attach the service routine here
}
/// --------------------------
/// Loop Routine
/// --------------------------
void loop()
{
}
/// --------------------------
/// Custom ISR Timer Routine
/// --------------------------
void timer_1_Isr(void)
{
Timer_count++;
Serial.print("Timer_count = ");
Serial.println(Timer_count);
}
http://playground.arduino.cc/Code/Timer1
https://oscarliang.com/arduino-timer-and-interrupt-tutorial/
http://coopermaa2nd.blogspot.tw/2011/07/41-blink-with-timer.html
訂閱:
張貼留言 (Atom)
[Sensor]MPU92/65
MPU92/65是很久以前買的感測器 基本上有加速度計、陀螺儀、電子羅盤、溫度計 以下是該電子商城的介紹 https://www.factoryforward.com/product/gy-87-mpu-9265-3-axis-9-dof-attitude-gyro-magnet...
沒有留言:
張貼留言