Hey there, so I am VERY new to this programming language and have just started using Arduino. I have run the LCD example sketch yet I want to try something different. I want the screen to display a string, wait, change it to a new one, wait and change and so on and so on in a loop.
Being that I don't really know what I am doing I sort of GUESSEd at teh code and of course it won't compile, would someone mid looking at the code and trying to see if they understand what I want to do and how to change it? THANKS IN ADVANCE!!!!
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop() {
// set the cursor to column 0, line 0
// (note: line 1 is the second row, since counting begins with 0):
char mystring[16];
lcd.setCursor(0, 1);
// print the value of mystring and alternate its value
lcd.print(mystring);
{
delay(115);
mystring = "So, i gotta say";
delay(115);
mystring = "that lcds.";
delay(115);
mystring = "Really Do.....";
delay(5000);
mystring = "Kick Butt!!!!";
}
}
So I updated my code to the following and am still getting an error at the lcd.print(mystring); line saying mystring was not declared in this scope:
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop() {
lcd.setCursor(0, 1);
lcd.print(mystring);
{
strcat (mystring, "So, i gotta say");
delay(115);
strcat (mystring,"that lcds.");
delay(115);
strcat (mystring,"Really Do.....");
delay(115);
strcat (mystring,"Kick Butt!!!!");
delay(5000);
}
}
Not sure what to do, I can't see what is wrong with my syntax...
Ok.. I trried that in my sketchand I am still getting errors, I am not familliar with the myLCDprint function etc here is where my code is at after the latest additions":
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop() {
lcd.setCursor(0, 1);
{
myLCDprint("So, i gotta say");
myLCDprint("that lcds.");
}
void myLCDprint(String mystring)
{
lcd.print(mystring);
}
}
I am getting a myLCDprint is not declared in this scope in the beginning void loop() function
So I changed it to this yet it still tells me myLCDprint is not declared
Can somone show me what I need to cahnge and how in this sketch? I am not experienced with syntax yet at all, so I could really use some help.
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop()
{
lcd.setCursor(0, 1);
myLCDprint("So, i gotta say");
myLCDprint("that lcds.");
void myLCDprint(String mystring)
{
lcd.print(mystring);
}
}
void loop()
{
lcd.setCursor(0, 1);
myLCDprint("So, i gotta say");
myLCDprint("that lcds.");
void myLCDprint(String mystring)
{
lcd.print(mystring);
}
}
The highlighted braces define the start and end of the loop function. Can you see that your function is defined INSIDE the loop function, which is not valid?
Move the function OUT of loop.
void loop()
{
lcd.setCursor(0, 1);
myLCDprint("So, i gotta say");
myLCDprint("that lcds.");
}
void myLCDprint(String mystring)
{
lcd.print(mystring);
}
It can be confusing at the beginning. Once you know it is hard to remember when you did not know, though some people here seem to think they leapt from the womb already fully formed and experienced programmers. They seem to tease more than help.
Your mistake is that the function is inside the loop. Note that "inside" does not mean "after". Inside means between the { and } which form the function called loop.
void Function ()
{
everything here is "inside" the function.
You need to count the opening and closing brackets to
see where the loop ends.
{
some more stuff, but still inside Function
}
}
Ah! Now I am outside Function.
Here is how to put it outside loop.
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void myLCDprint(String mystring)
{
lcd.print(mystring);
}
void loop()
{
lcd.setCursor(0, 1);
myLCDprint("So, i gotta say");
myLCDprint("that lcds.");
}
The above code is not supposed to compile and run, but illustrates how you should define functions.
This may simply be a consequence of "teach a man to fish" and "I don't plan to do your homework for you" (which is really another variant of the fish example), rather than any more sinister intent. For Arduino sketches, which tend to be pretty simple, it can be hard to find a balance between helping someone along and just giving a finished solution.
for me.. dont bother posting at all if you dont plan to help.
This being a help forum and posting in the newbie./help sections.. it leads one to believe that IS the place to get 'help' and not lip service.
I understand teaching a man to fish.. but that comes with educating them on how to do so.. so NEXT TIME they understand and can do so themselves.
comments (which are by large the trend in which MANY vet members respond) like:" Than you thought wrong" or " someone doesnt understand correctly" "someone has more reading to do".. and the list is so long is stupid remarks that took longer to post than actually providing help, that there just isnt enough time.
Do nothing but promote a bad attitude and image of the forum.. they dont teach anyone anything.. much less on how to become self-reliant due to the 'learning' they got.
and EASY is a relative term.. people who are new, it might NOT be easy for them.
IMHO, its better for a post to go ignored then post something snarky or not helpful... but just ++ to post count.. and perpetuate a bad image.
Not everyone is like that.. and I suppose its a learning curve for both parties.. those trying to learn.. as well as those trying to teach.. it just seems MANY members her DO forget they had to learn too (just because they've been EE's for XX years)...
Dont have answers or POSITIVE links to share them help the OP.. then just skip the thread all together!
This may simply be a consequence of "teach a man to fish" and "I don't plan to do your homework for you" (which is really another variant of the fish example), rather than any more sinister intent. For Arduino sketches, which tend to be pretty simple, it can be hard to find a balance between helping someone along and just giving a finished solution.
Sort of right, but there was a post which said "Who told you to put the function inside another function" which was clearly not going to be helpful to an absolute beginner. It maybe made the poster feel superior, but was clearly not intended to help the original poster.
Can you not remember having difficulties in a new subject?
You are right that we can't post full solutions, but fragments of examples are much better than cryptic replies.