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