int speakerPin = 2;
int buzzerPin = 4;
int buzzer2Pin = 0;
int xpin= A2;
int ypin= A1;
int zpin= A0;
int x, y, z;
void setup() {
// initialize the serial communication:
pinMode(xpin, INPUT);
pinMode(speakerPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(buzzer2Pin, OUTPUT);
//Serial.begin(9600);
}
void loop() {
bass();
}
void beep (unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds) // the sound producing function
{
int x;
long delayAmount = (long)(1000000/frequencyInHertz);
long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2));
for (x=0;x {
digitalWrite(speakerPin,HIGH);
delayMicroseconds(delayAmount);
digitalWrite(speakerPin,LOW);
delayMicroseconds(delayAmount);
}
}
void bass ()
{
x= analogRead(xpin);
y= analogRead(ypin);
z= analogRead(zpin);
beep(speakerPin,500+x,89);
beep(buzzerPin,90+y,80);
beep(speakerPin,290+z,x);
//beep(buzzer2Pin,700+z,10);
// beep(speakerPin,800+x,78);
//beep(speakerPin,x*0.7,sensorvalue%5);
//beep(speakerPin,xe*0.09,400); //
//delay(1000);
}