filmov
tv
Arduino tone driven by math functions

Показать описание
In this simple sketch the frequency of the Arduino "tone" is driven by mathematical functions to generate simple audio effects.
The function is chosen by pressing a button.
The first six functions are:
freq = 220;
freq = 440 + 220*sin(2*pi*i/period);
freq = 440 + i;
freq = 440 + period - i;
freq = 440 + 220*int(2*i/period);
freq = 2*(period - i)*(1 - int(2*i/period)) + (110 + random(55))*int(2*i/period);
where "i" runs from 0 to "period".
The function is chosen by pressing a button.
The first six functions are:
freq = 220;
freq = 440 + 220*sin(2*pi*i/period);
freq = 440 + i;
freq = 440 + period - i;
freq = 440 + 220*int(2*i/period);
freq = 2*(period - i)*(1 - int(2*i/period)) + (110 + random(55))*int(2*i/period);
where "i" runs from 0 to "period".