CCCPaste

"Buzzer Melody" rev_17

/********* Pleasedontcode.com **********

	Pleasedontcode thanks you for automatic code generation! Enjoy your code!

	- Terms and Conditions:
	You have a non-exclusive, revocable, worldwide, royalty-free license
	for personal and commercial use. Attribution is optional; modifications
	are allowed, but you're responsible for code maintenance. We're not
	liable for any loss or damage. For full terms,
	please visit pleasedontcode.com/termsandconditions.

	- Project: "Buzzer Melody"
	- Source Code compiled for: Arduino Uno
	- Source Code created on: 2023-12-19 22:23:21

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* play melody of jingle bells one time. */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 
#include 

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);

/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t alarm_ActiveBuzzer_output_PIN_D2 = 2;

/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
ezBuzzer buzzer(alarm_ActiveBuzzer_output_PIN_D2);

void setup(void)
{
    // put your setup code here, to run once:
    pinMode(alarm_ActiveBuzzer_output_PIN_D2, OUTPUT);
}

void loop(void)
{
    // put your main code here, to run repeatedly:

    // System Requirement 1: Play melody of jingle bells one time
    int melody[] = {
        NOTE_E4, NOTE_E4, NOTE_E4, NOTE_E4, NOTE_E4, NOTE_E4, NOTE_E4, NOTE_G4, 
        NOTE_C4, NOTE_D4, NOTE_E4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_F4, 
        NOTE_E4, NOTE_E4, NOTE_E4, NOTE_E4, NOTE_E4, NOTE_D4, NOTE_D4, NOTE_E4, 
        NOTE_D4, NOTE_G4
    };

    int noteDurations[] = {
        8, 8, 4, 8, 8, 4, 8, 8, 8, 8, 2, 8, 8, 8, 8, 8, 8, 8, 16, 16, 8, 8, 8, 8, 4, 4
    };

    int length = sizeof(melody) / sizeof(int);
    buzzer.playMelody(melody, noteDurations, length);

    // Delay for 5 seconds before playing the melody again
    delay(5000);
}