Error message

So this is my code;

include "file.h"

int led1 = 2; int led2 = 3; int led3 = 4; int led4 = 5; int led5 = 6; int led6 = 7; int led7 = 8; int led8 = 9; int lightsensor = A0; const int buzzer = 10; int melody[] = {NOTE_A4, NOTE_A4, NOTE_A4, NOTE_F4, NOTE_C5, NOTE_A4, NOTE_F4, NOTE_C5, NOTE_A4, NOTE_E5, NOTE_E5, NOTE_E5, NOTE_F5, NOTE_C5, NOTE_A4, NOTE_F4, NOTE_C5, NOTE_A4};//you can see what the notes mean in kamissexyandiknowit.h int durations[] = {4, 4, 4, 5, 16, 4, 5, 16, 2, 4, 4, 4, 5, 16, 4, 5, 16, 2}; int tempo = 120; void setup() { pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(led5, OUTPUT); pinMode(led6, OUTPUT); pinMode(led7, OUTPUT); pinMode(led8, OUTPUT); pinMode(buzzer, OUTPUT); pinMode(lightsensor, INPUT); Serial.begin(9600); playTune(melody, durations, tempo); }
void loop() { int lightsensorvalue = analogRead (lightsensor); Serial.println(lightsensorvalue); if (lightsensorvalue >= 400) { playTune(notes[], durations[], BPM); digitalWrite(led1, HIGH); digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, HIGH); digitalWrite(led7, HIGH); digitalWrite(led8, HIGH); } }
void playTune(int notes[], int durations[], int BPM) { int tuneSize = sizeof(melody) / sizeof(int); for (int thisNote = 0; thisNote < tuneSize; thisNote++) {
int noteDuration = (int)((1000 * (60 * 4 / BPM)) / durations[thisNote] + 0.); tone(buzzer, notes[thisNote],noteDuration); int pauseBetweenNotes = noteDuration * 1.20; delay(pauseBetweenNotes); noTone(buzzer); } }

And whenever I compile it, I get these errors;

sketch_jun11a.ino: In function 'void loop()': sketch_jun11a.ino:37:14: error: 'notes' was not declared in this scope sketch_jun11a.ino:37:20: error: expected primary-expression before ']' token sketch_jun11a.ino:37:33: error: expected primary-expression before ']' token sketch_jun11a.ino:37:36: error: 'BPM' was not declared in this scope Error compiling.

Please help me ASAP

Welcome to the Forum. Before you post your code, you might want to use Ctrl-T in the IDE so that it is formatted in a human-readable format.

Since you have multiple data definitions on one line, it's very hard to see where the errors are. Move each data definition to its own line. Also, you have comment characters on a line and then data definitions on the same line after that. Once the compiler sees the comment characters, it ignores the rest of the line.

Reformat your code, recompile it, and work through the errors one-by-one.

Oh my.
I hope the code you posted was placed in single line format in error.

Please, one line per statement!

I agree with econjack and LarryD.

However, I will add that in the function loop(), you have the statement:

playTune(notes[], durations[], BPM);

but (just as the compiler told you), you have not defined notes[] or BPM. If econjack is right, durations[] is not defined either.