Go Down

Topic: How to sync light to closely whisper? What is the wrong with it? (Read 99 times) previous topic - next topic

Thataudruinokid



const int buzzerPin = 4;    // connect the buzzer to pins 4, 7
const int songLength = 16;  // sets the number of notes of the song

// Notes is an array of text characters corresponding to the notes
// in your song. A space represents a rest (no tone)

char notes[songLength] = {
  'e', 'e', 'd', 'a','a', 'f', 'e', 'd', 'a', 'f', 'c', 'b', 'f', 'd'};

// beats[] is an array of values for each note. A "1" represents a quarter-note,
// "2" a half-note, and "4" a quarter-note.
// Don't forget that the rests (spaces) need a length as well.

int beats[songLength] = {
  1, 2, 1, 1, 1.5, 2, 1.5, 2, 1.5, 1.5, 2, 1.5, 2.5};

int tempo = 120;  // The tempo is how fast to play the song (beats per second).

void setup() {
  // put your setup code here, to run once:

  // setup all 8 pins as OUTPUT - notice that the list is "indexed" with a base of 0.
  pinMode(ledPins[0],OUTPUT);  // ledPins[0] = 2
  pinMode(ledPins[1],OUTPUT);  // ledPins[1] = 3
  pinMode(ledPins[2],OUTPUT);  // ledPins[2] = 4
  pinMode(ledPins[6],OUTPUT);  // ledPins[6] = 8
 
}

slipstick

That's not a complete sketch. It has no chance of compiling. When you have put enough in it to at least make it compile ask again.

To get you going:
Every sketch needs a loop().
And you need to look up what "int" means. Hint: values like 1.5 and 2.5 don't fit in one.

Steve

Go Up