Domi04151309

Examples

Board with LEDs

Here you find some examples for the library. They all work with the above shown circuit. It shows you how to use this library and what you can do with it.

Short example

#include <Notes.h>			//Includes the library

Notes n(64,16);				//Sets the beatLEDtime to 64 and the noToneDelay to 16

void setup()
{
  Serial.begin(9600);  			//Starts the serial monitor for debugging
  n.speakerSetup(3);  			//Sets the speakerPort to 3 and the beats per minute to 120
  n.toneLEDSetup(6,7,8,9,10,11,12,13);  //Sets the beatLED to port 6 and the toneLEDs to the ports 7, 8, 9, 10, 11, 12 and 13
  n.toneLEDState();			//Turns on the tone LEDs
}

void loop()
{
  n.note(NOTE_G4,4);			//Plays the song
  n.note(NOTE_A4,4);
  n.note(NOTE_B4,4);
  n.note(NOTE_C5,4);
  n.note(NOTE_D5,2);
  n.note(NOTE_D5,2);
  n.note(NOTE_E5,4);
  n.note(NOTE_E5,4);
  n.note(NOTE_E5,4);
  n.note(NOTE_E5,4);
  n.note(NOTE_D5,1);
  n.note(NOTE_E5,4);
  n.note(NOTE_E5,4);
  n.note(NOTE_E5,4);
  n.note(NOTE_E5,4);
  n.note(NOTE_D5,1);
  n.note(NOTE_C5,4);
  n.note(NOTE_C5,4);
  n.note(NOTE_C5,4);
  n.note(NOTE_C5,4);
  n.note(NOTE_B4,2);
  n.note(NOTE_B4,2);
  n.note(NOTE_A4,4);
  n.note(NOTE_A4,4);
  n.note(NOTE_A4,4);
  n.note(NOTE_A4,4);
  n.note(NOTE_G4,1);
}
		

Example with integers and full commands

int g=396;
int a=440;
int b=495;
int hc=528;
int hd=594;
int he=660;

#include <Notes.h>			//Includes the library

Notes n(64,16);				//Sets the beatLEDtime to 64 and the noToneDelay to 16

void setup()
{
  n.speakerSetup(3,120);		//Sets the speakerPort to 3 and the beats per minute to 120
  n.toneLEDSetup(6,7,8,9,10,11,12,13);	//Sets the beatLED to port 6 and the toneLEDs to the ports 7, 8, 9, 10, 11, 12 and 13
  n.toneLEDState(ON);			//Turns on the tone LEDs
}

void loop()
{
  n.note(g,4,false,false);		//Plays the song
  n.note(a,4,false,false);
  n.note(b,4,false,false);
  n.note(hc,4,false,false);
  n.note(hd,2,false,false);
  n.note(hd,2,false,false);
  n.note(he,4,false,false);
  n.note(he,4,false,false);
  n.note(he,4,false,false);
  n.note(he,4,false,false);
  n.note(hd,1,false,false);
  n.note(he,4,false,false);
  n.note(he,4,false,false);
  n.note(he,4,false,false);
  n.note(he,4,false,false);
  n.note(hd,1,false,false);
  n.note(hc,4,false,false);
  n.note(hc,4,false,false);
  n.note(hc,4,false,false);
  n.note(hc,4,false,false);
  n.note(b,2,false,false);
  n.note(b,2,false,false);
  n.note(a,4,false,false);
  n.note(a,4,false,false);
  n.note(a,4,false,false);
  n.note(a,4,false,false);
  n.note(g,1,false,false);
}
		


Back to Mainpage