本帖最後由 havy 於 2014-11-21 13:09 編輯
Pins 5 and 6: controlled by Timer 0 in fastPWM mode (cycle length = 256)
Setting Divisor Frequency 0x01 1 62500 0x02 8 7812.5 0x03 64 976.5625 0x04 256 244.140625 0x05 1024 61.03515625
TCCR0B = TCCR0B & 0b11111000 |<setting>;TCCR0B = TCCR0B & 0b11111000 | <setting>; 10kHz 沒有,但有接近的...7.8KHz 可以在void setup() 大括號內加入下面這行 TCCR0B = TCCR0B & 0b11111000 | <0x02>; 再使用pin 5或6 . Reference:http://playground.arduino.cc/Main/TimerPWMCheatsheet |