I am trying to design a program where there is two scales for a keyboard that plays a tone when a input is pressed. I am using the tone library to get the tone through a speaker. I have got the scale working so far but my problem is I get this error:
Arduino: 1.6.5 (Windows 7), Board: "Arduino Uno"
Multi-scale_Keyboard.ino: In function 'void loop()':
Multi-scale_Keyboard:24: error: request for member 'begin' in 'tone', which is of non-class type 'void(uint8_t, unsigned int, long unsigned int) {aka void(unsigned char, unsigned int, long unsigned int)}'
Multi-scale_Keyboard:25: error: expected identifier before numeric constant
Multi-scale_Keyboard.ino: In lambda function:
Multi-scale_Keyboard:25: error: expected '{' before ')' token
Multi-scale_Keyboard.ino: In function 'void loop()':
Multi-scale_Keyboard:25: error: 'play' was not declared in this scope
request for member 'begin' in 'tone', which is of non-class type 'void(uint8_t, unsigned int, long unsigned int) {aka void(unsigned char, unsigned int, long unsigned int)}'
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Here is my code so far:
#include <Tone.h>
int scalePot = A0;
int C_note = 2;
int D_note = 3;
int E_note = 4;
int F_note = 5;
int G_note = 6;
void setup() {
// put your setup code here, to run once:
pinMode (scalePot, INPUT);
pinMode (C_note, OUTPUT);
pinMode (D_note, OUTPUT);
pinMode (E_note, OUTPUT);
pinMode (F_note, OUTPUT);
pinMode (G_note, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
while ( 0 < scalePot < 511.5);
if (C_note = 1);
tone.begin(2);
play(261.63,[1]);
}
Could anybody lend a hand on why I am getting this error. I am new to Arduino so please reply in a simple way as to not over complicate my brain!
That semicolon's not going to help when you've discovered why "tone" doesn't have a "begin" method.
Nor is the assignment which will ensure the "if" is always true.
while ( 0 < scalePot < 511.5);
There's nothing wrong with that, syntactically, so it won't give you an error, but it probably doesn't do what you intend
I have sorted out that error now im getting this error:
Arduino: 1.6.5 (Windows 7), Board: "Arduino Uno"
Multi-scale_Keyboard.ino: In function 'void loop()':
Multi-scale_Keyboard:27: error: expected identifier before numeric constant
Multi-scale_Keyboard.ino: In lambda function:
Multi-scale_Keyboard:27: error: expected '{' before ')' token
Multi-scale_Keyboard.ino: In function 'void loop()':
Multi-scale_Keyboard:27: error: invalid user-defined conversion from 'loop()::__lambda0' to 'uint32_t {aka long unsigned int}' [-fpermissive]
Multi-scale_Keyboard.ino:27:26: note: candidate is: loop()::__lambda0::operator void (*)()() const <near match>
Multi-scale_Keyboard.ino:27:26: note: no known conversion for implicit 'this' parameter from 'void (*)()' to 'uint32_t {aka long unsigned int}'
Multi-scale_Keyboard.ino: At global scope:
Multi-scale_Keyboard:29: error: expected declaration before '}' token
expected identifier before numeric constant
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
This is how my code looks now.
#include <Tone.h>
Tone tone1;
int scalePot = A0;
int C_note = 2;
int D_note = 3;
int E_note = 4;
int F_note = 5;
int G_note = 6;
void setup() {
// put your setup code here, to run once:
pinMode (scalePot, INPUT);
pinMode (C_note, OUTPUT);
pinMode (D_note, OUTPUT);
pinMode (E_note, OUTPUT);
pinMode (F_note, OUTPUT);
pinMode (G_note, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
while ( 0 < scalePot < 511.5);
if (C_note = 1)
tone1.begin(2);
tone1.play(261.63, [1]);
}
}
that is the frequency in hertz of the tone and the duration that it plays for. How am i supposed to sort out the while and for loop? Would you help me please?
oh i understand now, i need to do an analog read to find out the value and then read this into the while loop which will then do what i want. I'll test that now...
its all working now except now its saying that there is no such file or directory called wiring. I'm not even using one called wiring! what's wrong now?
Arduino: 1.6.5 (Windows 7), Board: "Arduino Uno"
C:\Program Files (x86)\Arduino\libraries\Tone\Tone.cpp:26:20: fatal error: wiring.h: No such file or directory
#include <wiring.h>
^
compilation terminated.
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.