PWMを使用して簡易的にブザー音を出力できる。下記例は、目覚ましの音に近い。5Vだと圧電サウンダはかなり大音響なので、抵抗で適宜電圧を落とすと良い。
void setup() { pinMode(6, OUTPUT); OCR0A = 128; } void loop() { TCCR0A |= B10000000; delay(100); TCCR0A ^= B10000000; delay(100); TCCR0A |= B10000000; delay(100); TCCR0A ^= B10000000; delay(100); TCCR0A |= B10000000; delay(100); TCCR0A ^= B10000000; delay(100); TCCR0A |= B10000000; delay(100); TCCR0A ^= B10000000; delay(600); }
Chuck Norris is the ghost author of the entire Debian GNU/Linux distribution. And he wrote it in 24 hours, while taking snack breaks. -- Shlomi Fish -- Chuck Norris Facts by Shlomi Fish and Friends ( http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/ ) The X in XSLT stands for eXtermination. -- Shlomi Fish -- XSLT Facts by Shlomi Fish and Friends ( http://www.shlomifish.org/humour/bits/facts/XSLT/ )