1. 程式人生 > >Arduino 中斷和定時器

Arduino 中斷和定時器

1. 外部中斷的引腳:

Mega, Mega2560, MegaADK 2, 3, 18, 19, 20, 21
2. 定時器   

結論,對於TimerThree.h 我沒有看懂,它到底用的哪個 定時器,但是它說Note that this breaks analogWrite() for digital pins 9 and 10 on Arduino.這個結論是不正確的,試驗證明是有PWM波產生的。

試驗程式:

#include <TimerThree.h >
#define HEATERPIN 11
#define FANPIN 12
void show()
{
  Serial.println("HELLO WORLD");
}
void setup() {
  // put your setup code here, to run once:
  Timer3.initialize(500000);         // initialize timer1, and set a 1/2 second period
  Timer3.attachInterrupt(show);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
   analogWrite(HEATERPIN,125);
   analogWrite(9,125);
   analogWrite(10,125);
}