Hi there! So I'm new to Arduino; a college course I'm taking sprang out of the blue with this and I've never even heard of, let alone thought of ever taking on this kind of project, but I'm very eager to learn.
So I am trying to create a program in which I am able to change the text on a 16x2 display by using the joystick and button inside of it to select and change the text. For example, I want to select something, so I move right once to display "YouTube" and press in the joystick to click the button to change that text to a "tinyurl" or something along those lines.
I have been following this guide on how to do all this since I am awful and new to this whole thing, however I am getting some verify errors that I feel should not happen, mostly saying that things are not defined properly or "redefined", so I've uploaded the .ino here. What am I doing wrong, or better yet, what am I doing right so far? I'd love to see what else I could do instead of my "I know python and C# and thats what I'll attempt to do" pseudocode that barely works. Thank you for the help in advance!
Awesome, I should've remembered that from Python. So I actually got it to work, however it does not move when I move the joystick. Here's my current running code:
A case statement or "else if" ... but even then because you are running in loop the code will execute on the next loop. Maybe a small delay before you check the joystick again.
Sounds good, thank you. I will go ahead and try that out and see what happens. How exactly would you write a case statement for this expression? An "else if" is causing the refresh loop to loop slower and now be noticeable.
Firstly, MAJOR kudos for using code tags (i.e. code formatted correctly for the forum) without prompting in your first posting. You have no idea how rare that is!
Now, about Serial Monitor. Yes, it displays output in the Serial Monitor, which you open by selecting Serial Monitor in the IDE window. When it's open, note the baud rate (in my IDE, it's at the bottom of the window.
Now, in setup() in your code, add a line, "Serial.begin(XXXX);", where XXXX is the number just noted.
From there on, whenever you want to find out what some variable's value is, or you want to flag where the code execution is, just do a Serial.println("some message"); and that will appear in the monitor. It's an incredible debugging tool. There are nuances, but that's the crux.
There are tutorials about this, search Arduino.cc.
Gotcha! Thank you for that information. I knew my C# lab reports would be useful eventually for formatting purposes! So I ended up scrapping my joystick and I am now using three buttons in place of that for input. However, when the button is pressed, the display flips through the options so fast it does not actually stay long enough to be able to cycle through the menu itself. Here is the last verified version of my code that did do that part:
When I now press Button2, it quickly flashes the first choice (Wikipedia) before immediately resetting to the first text. I attempted a switch which I will post under this paragraph but that does not seem to do anything now. Do you happen to know what could be going wrong here and how to fix that?
// This snippet is right after "lcd.print(QR Code Links)"
switch (buttonPin2)
{
case HIGH:
switch (count)
{
case 0:
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("Youtube");
selection = 1;
count++;
break;
case 1:
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Wikipedia");
selection = 2;
count++;
break;
case 2:
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Netflix");
selection = 3;
count++;
break;
case 3:
count = 0;
break;
}
}
}
If you want time to read what you printed, you might add dela(1000); after the println() statement.
Later (if your code will actually take you to netflix) you may need to remove it.