Buzzer sound with absolute tan wave

The idea was to create a whining sound. So I experimented with Tan wave. After all whining sound is the most annoying sound of all.

Here’s the codes.

//test tan waveform
const int buzzPin = 9;
const double pi = 3.142;
void setup()
void loop()
for(float t = 1; t < 4; t= t + 0.001)
double y = 80 * tan (t * pi); //the tan function that create the weird sound
int thisPitch = abs(y);
thisPitch = map(thisPitch,0,1000,500,700);
//thisPitch = constrain (thisPitch,500,700);
//for (int t =0; t < 255; t=t+5)
// analogWrite(buzzPin,t);
//delay (30);

Next I would like to try instead of “absoluting” the y value, I just map thisPitch from negative number to positive number so basically I just shift the zero value.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: