Hi,
I have some code that I am able to compile in the Arduino IDE but when I try and compile it in VS2010 it give me a compiling error. It started when I started implementing a structure.
These are the errors I get
Compiling 'funWithSounds' for 'Arduino Uno'
funWithSounds.ino : variable or field 'playBack' declared void
funWithSounds.ino : 'musicNote' was not declared in this scope
funWithSounds.ino : expected primary-expression before 'int'
Error compiling
This is the code associated with the sections in descending order.
This is the Definition of the Structure
struct musicNote
{
char note; //note
unsigned int beat; //length played
};
I used a function declaration at the beginning of the program
void playBack(musicNote note[], int arrySize); //plays back contents in musicNote
This where I declared my musicNote variable
musicNote note[MAX]; //all notes are recorded to this structure
This is how the function is called.
playBack(note, tuneLen);
This is the definition of the function
void playBack(musicNote note[], int arrySize)
{
for( int i = 0; i < arrySize; i++)
{
if (note[i].note == 'c')
for (int j = 0; j < note[i].beat; j++)
playNote(soundPin, 1915);
if (note[i].note == 'b')
for (int j = 0; j < note[i].beat; j++)
playNote(soundPin, 1700);
if (note[i].note == 'a')
for (int j = 0; j < note[i].beat; j++)
playNote(soundPin, 1519);
if (note[i].note == '.')
{
sensorValue = analogRead(sensorPin);
Serial.print(sensorValue);
Serial.print('\n');
delay((note[i].beat)/(sensorValue + 50));
}
}
}
Before I added the structure the program compiled fine and uploaded to the Arduino with no issues. Thanks for any help.
TPBW4321