Hi
This is my first time posting/asking for help and my first Arduino projects (SMARS). I am using a UNO R3 and a L298P as per this link http://www.mantech.co.za/Datasheets/Products/EX029.pdf which states “Onboard buzzer (D4), you can set the astern alarm ringtone”.
I am trying to enable the onboard buzzer and have tried the following 2 code examples:-
int buzzer = 4;
void setup()
{
pinMode(buzzer, OUTPUT);
}
void loop() {
for (int i=40; i<256; i++)
{
tone(buzzer, 1000); //1KHz
delay(1000);
noTone(buzzer);
delay(1000);
}
}
int speakerPin = 4; //buzzer pin?
//#define speakerPin 1
void setup()
{
pinMode(speakerPin, OUTPUT);
}
void loop()
{
for (int i=0; i<255; i++)
{
digitalWrite(speakerPin, HIGH);
delayMicroseconds(500);
digitalWrite(speakerPin, LOW);
delayMicroseconds(500);
}
}
Neither code example works, any help would be most appreciated.