最初コミット

This commit is contained in:
2026-03-01 17:41:24 +09:00
commit 01705ab778
2 changed files with 228 additions and 0 deletions

12
play.ino Normal file
View File

@@ -0,0 +1,12 @@
void play(byte pin, unsigned int frequency, byte duty, unsigned long duration) {
unsigned long period = 1000000UL / frequency;
unsigned long high = period * duty / 100UL;
unsigned long low = period - high;
for (unsigned long i = 0; i < duration * 1000UL; i += period) {
digitalWrite(pin, HIGH);
delayMicroseconds(high);
digitalWrite(pin, LOW);
delayMicroseconds(low);
}
}