hi guys :))
i need your help. im new to programming so i need some of your suggestions regarding on my program.
i got a lot of compiling errors whenever i verify my program. here's my program. check on this.
i hope you can help me :)) thank you and God bless
#include <Tone.h>
const boolean DEBUG = false;
const int CALIBRATION_PIN = A5;
const int SPEAKER_PIN = 8;
const int SENSOR_COUNT = 3;
typedef struct
{
int pin;
int note;
}
sensor_type;
sensor_type sensor[SENSOR_COUNT];
Tone notePlayer;
void setup(void)
{
if (DEBUG) {
Serial.begin(9600);
}
sensor[0].pin = A0; // analog input 0, etc...
sensor[0].note = NOTE_G3;
sensor[1].pin = A1;
sensor[1].note = NOTE_D4;
sensor[2].pin = A2;
sensor[2].note = NOTE_A4;
notePlayer.begin(SPEAKER_PIN);
}
void loop(void)
{
int calibration = analogRead(CALIBRATION_PIN);
if (DEBUG) {
Serial.print("cal: ");
Serial.print(calibration);
}
int activeSensor = -1;
for (int p = 0 ; p < SENSOR_COUNT ; p++) {
int sensor_value = analogRead(sensor[p].pin);
if (DEBUG) {
Serial.print("\tsensor ");
Serial.print(p);
Serial.print(": ");
Serial.print(sensor_value);
}
if ( sensor_value < calibration ) {
activeSensor = p;
if (DEBUG) Serial.print("!"); // "!" indicates note being played
}
}
if (DEBUG) Serial.println();
if (activeSensor == -1) {
notePlayer.stop();
}
else {
notePlayer.play(sensor[activeSensor].note);
}
if (DEBUG) delay(1000);
}
compiling errors...
C:\Users\Vanessa\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::begin(uint8_t)':
C:\Users\Vanessa\Documents\Arduino\libraries\Tone\Tone.cpp:121: error: 'bitWrite' was not declared in this scope
C:\Users\Vanessa\Documents\Arduino\libraries\Tone\Tone.cpp:123: error: 'digitalPinToPort' was not declared in this scope
C:\Users\Vanessa\Documents\Arduino\libraries\Tone\Tone.cpp:123: error: 'portOutputRegister' was not declared in this scope
C:\Users\Vanessa\Documents\Arduino\libraries\Tone\Tone.cpp:124: error: 'digitalPinToBitMask' was not declared in this scope
C:\Users\Vanessa\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::play(uint16_t, uint32_t)':
C:\Users\Vanessa\Documents\Arduino\libraries\Tone\Tone.cpp:198: error: 'OUTPUT' was not declared in this scope
C:\Users\Vanessa\Documents\Arduino\libraries\Tone\Tone.cpp:198: error: 'pinMode' was not declared in this scope
C:\Users\Vanessa\Documents\Arduino\libraries\Tone\Tone.cpp:294: error: 'bitWrite' was not declared in this scope
C:\Users\Vanessa\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::stop()':
C:\Users\Vanessa\Documents\Arduino\libraries\Tone\Tone.cpp:361: error: 'digitalWrite' was not declared in this scope