I have spent hours researching and trying to fix this but my knowledge with code just isn't quite there yet. The first file "LastHope..." is the working code for a basic line follower that i modified to include my motor shield library. I have tested this code and it works as it should. Once i tried to implement 2*16 LCD,button, and a buzzer that is where i ran into issues. I Followed a guide on instuctables (I can provide a link upon request not sure on rules) unfortunately the code (second file "Linus_Line...") provided with this build has multiple errors such as:
Linus_Line_Follower:13: error: 'BUTTON_PULLUP_INTERNAL' was not declared in this scope
Button button = Button(2,BUTTON_PULLUP_INTERNAL); // pin 2 - button
^
C:\\Arduino\Linus Line Follower\Linus_Line_Follower\Linus_Line_Follower.ino: In function 'void setup()':
Linus_Line_Follower:76: error: 'class Button' has no member named 'isPressed'
while(!button.isPressed()){
^
C:\\Arduino\Linus Line Follower\Linus_Line_Follower\Linus_Line_Follower.ino: In function 'void loop()':
Linus_Line_Follower:123: error: 'class Button' has no member named 'isPressed'
while(!button.isPressed()){
^
I did manage to add this code to mine and eliminate the errors but the robot ended up being unresponsive. If anyone here could help out i would appreciate it very much.
As far as i can tell i have two options :
incorporate code for calibration and music ie: button,lcd,buzzer into the working code
eliminate errors for LINUS code and modify to work with my motor shield
If there are any formatting issues bare with me, and if i can provide anymore info just ask i will provide all that is needed.
Thanks in advance for any help
Provide these 2 because they are not standard in the arduino library and I do not know what version you have. It would be better if you could just upload the files/libraries, however, if that is too complicated simply link us to the SAME download pages that you got the libraries from.
Let me know if that works, meanwhile ill try to find the website where i got them just in-case. i also included the motor shield one just in-case from what i read it is not a standard one.
Ps991:
simply link us to the SAME download pages that you got the libraries from.
+1, more often than not, you can view the source code at the library site. Also, if you post the library code it may lack documentation and explanations that are on the library site. Many libraries consist of multiple files, not practical to post.
for starters, notice how in Button.h there is no BUTTON_PULLUP_INTERNAL
This is what is defined...
#define PULLUP HIGH
#define PULLDOWN LOW
Although, isPressed() is a method of the Button class, so not sure why you are getting that error...I tried the library's example and it worked for me...
Ok, i thought i got it. I set button to pin 2 and pin 2 to input.
int pinButton = 2; // Button pin
void setup(){
lcd.begin(16, 2);
Serial.begin(9600); // Initialize the serial communication
pinMode(pinAudio, OUTPUT); // Define the Audio pin as an output
But there seems to be more errors now, i must not be understanding this code as much as i thought i did.
New Error:
C:\Arduino\Linus Line Follower\Linus_Line_Follower\Linus_Line_Follower.ino: In function 'void setup()':
Linus_Line_Follower:78: error: could not convert 'digitalWrite(2u, 1u)' from 'void' to 'bool'
while(digitalWrite(2, HIGH);){
^
Linus_Line_Follower:78: error: expected ')' before ';' token
while(digitalWrite(2, HIGH);){
^
Linus_Line_Follower:78: error: expected primary-expression before ')' token
while(digitalWrite(2, HIGH);){
^
Linus_Line_Follower:78: error: expected ';' before ')' token
Linus_Line_Follower:99: error: 'qtr' was not declared in this scope
qtr.calibrate();
^
C:\Users\Eddie\Documents\Arduino\Linus Line Follower\Linus_Line_Follower\Linus_Line_Follower.ino: In function 'void loop()':
Linus_Line_Follower:125: error: could not convert 'digitalWrite(2u, 1u)' from 'void' to 'bool'
while(digitalWrite(2, HIGH);){
^
Linus_Line_Follower:125: error: expected ')' before ';' token
while(digitalWrite(2, HIGH);){
^
Linus_Line_Follower:125: error: expected primary-expression before ')' token
while(digitalWrite(2, HIGH);){
^
Linus_Line_Follower:125: error: expected ';' before ')' token
Linus_Line_Follower:138: error: 'qtr' was not declared in this scope
unsigned int position = qtr.readLine(sensors);
^
And i still have no idea how to get this code to work with my shield like i did with the working code.
Thanks for all your help by the way it is much appreciated sorry i don't understand the code as well as i should.
This is wrong in 2 ways, the first is that you have a semicolon stuck in there when it shouldn't be, and the second is that digitalWrite() is a void returned function meaning that it does not return anything. So basically you are checking if nothing doesn't equal 0, which doesn't make sense. That's why you get these errors
error: expected ')' before ';' token
error: could not convert 'digitalWrite(2u, 1u)' from 'void' to 'bool'
That kind of makes sense but i don't know how to fix it. To answer your question I believe it is just a confirmation for multiple things throughout the calibration process. As i said before I'm just following this guide, and figured the code would be working before i started.
You should be able to get it to work, however, we need updated code to give feedback. A good way to get things to work is to separate individual components and get them to work by themselves first. Then add that code to your existing code, you may hit some errors or bugs, and thats when you come back and post your questions. And as always, be detailed in your questions and statements, don't assume we know everything.
I know that, however, the pin is being initialized inside one of the libraries during an object creation.
When I said "set a pin to an input" I meant via the object creation, then type that to make it a pullup. But yes, you could also create the object, then use pinMode again.
"which predates your joining the forum by some years" <-- Was that a snarky way of saying "you should know better"?