A program i copied mostly. You'll need, an arduino board, piezo buzzer, led, arduino software. You might need, breadboard, jumper wires. Put the negatives pins of the buzzer and led into the ground pin, and put the positives where ever you want (but make sure to edit the code). I put mine at pin 13 and 52, because I have the ARDUINO MEGA! Here is the code and it will work if you change the pin numbers to where you have your buzzer and led! and also put a less than sign where i say to put one! it should work then. just copy and paste:
void setup() {
pinMode(11, OUTPUT); //make sure to change the pin number based on your setup
pinMode(52, OUTPUT);
}
void loop() {
buzz(11, 600, 500); //600 is the pitch, 300 is very low, 2000 is very high and 500 is the time, 1000 is a second
digitalWrite(52, LOW); //change pin numbers if necessary
delay(1000); // time inbetween flashes/buzzes
digitalWrite(52, HIGH);
}
void buzz(int targetPin, long frequency, long length) { //this is a bunch of crap i didn't understand
long delayValue = 1000000/frequency/2;
long numCycles = frequency * length/ 1000;
for (long i=0; i ((((****PUT A LESS THAN SYMBOL IS PLACE OF THIS))) numCycles; i++){
digitalWrite(targetPin,HIGH);
delayMicroseconds(delayValue);
digitalWrite(targetPin,LOW);
delayMicroseconds(delayValue);
}
}