arduino - Coding multiple Piezos in C# -


Can someone help me write this function? At two different pizzas, I should be able to play two different tunics at a time. What should I change my code?

  zero beep (unsigned four speaker pins, int freq1, int freq2, milliseconds in long) {int x; Long-term 1 = (long) (1000000 / freq 1); Long delayed 2 = (long) (1000000 / freq 2); Long Loptim = (Long) ((Time Inmilicand's * 1000) / (Delay 1 * 2)); For (x = 0; x & lt; loopTime; x ++) {digital white (speaker pin 1, high); DigitalWrite (speakerPin2, high); DelayMicroseconds (delayAmount2); DigitalWrite (speakerPin1, less); DigitalWrite (speakerPin2, less); DelayMicroseconds (delayAmount2); You should use timers and interrupts to provide more accurate time, And run from  loop ()  independently. 

There is already an Arduino function, tone () which plays a note at one time, but it can not be optimized as more than one because it Depends on PWM of a timer.

Instead, you will need to write an interrupt service routine that toggles a pin, puts it in the next center to set the right time and the future at the right time. There will be a need to use attachInterrupt () , and there will be some global unstable variables to manipulate tones.

This is a standard student practice, and there should be many examples on the web.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -