Created
November 17, 2016 14:09
-
-
Save zyouyowa/1b35b26a08891839229b0efcf1303dc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TCCR0Bをいじっても同じ時間待てるようにするdelay | |
void delay_tccr0b(float ms){ | |
delay(ms * 64.0 / pow(8, TCCR0B-1)); | |
} | |
void setup(){ | |
//leonardoではTCCR0Bは3ピンに影響 | |
pinMode(3, OUTPUT); | |
//PWMの周波数が62.5kHzになる | |
TCCR0B=(TCCR0B & 0b11111000) | 0x01; | |
} | |
void loop(){ | |
//0-255なので、128でduty比50% | |
analogWrite(3, 128); | |
Serial.println(TCCR0B); | |
delay_tccr0b(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment