I am currently building a library for Arduino for the purpose of simplifying a program I made earlier on that allows for more accessible customization with the tone command. The problem arises when I try to use the library I have made. (a .h and a .cpp file).
The specific parts causing the issue,
Buzzer::Buzzer(int pin) {
pinMode(pin, OUTPUT);
_pin = pin;
}
BetterToneNote::BetterToneNote(int note) {
_note = note;
for (int noteAmount = 0; noteAmount < 1; noteAmount++){ //Allows for self-correcting note play
// to calculate the note duration, take one second divided by the note type
int betterNoteDuration = 1000 / betterNoteDurations[betterNoteAmount];
tone(pin, noteArray[note], betterNoteDuration);
delay(2000);
}
}
The error I get back from AtmelStudio,
library.cpp: 36:14: error: 'pin' was not declared in this scope
tone(pin, noteArray[note], betterNoteDuration)
Any help is appreciated. Thanks in advance!