diff --git a/DDS.h b/DDS.h index 8115dcc..be30411 100644 --- a/DDS.h +++ b/DDS.h @@ -170,7 +170,7 @@ public: void on(unsigned short duration) { // Duration in ticks from milliseconds is: // t = (1/refclk) - tickDuration = (duration * refclk) / 1000; + tickDuration = (unsigned long)((unsigned long)duration * (unsigned long)refclk) / 1000; timeLimited = true; running = true; } @@ -186,7 +186,7 @@ public: // Blocking version void playWait(unsigned short freq, unsigned short duration) { play(freq, duration); - delay(duration * 1000); + delay(duration); } // Our maximum clock isn't very high, so our highest diff --git a/examples/DDS/DDS.ino b/examples/DDS/DDS.ino index 245bb79..394ad18 100644 --- a/examples/DDS/DDS.ino +++ b/examples/DDS/DDS.ino @@ -8,9 +8,8 @@ void setup() { pinMode(3, OUTPUT); pinMode(11, OUTPUT); dds.start(); - dds.setFrequency(440); + dds.playWait(600, 3000); dds.on(); - delay(5000); } void loop() {