Hello all. For starters I am a complete beginner with anything Arduino and most electrical wiring as well. Sorry in advance if any of my formatting in this post is bad.
I'm working on a project for a friend's birthday and am running out of time. I started with an Arduino Uno, breadboard, LCD display, push button, and a toggle power button since I wanted it battery powered. My only goal is to have the push button display a message on the LCD for 5 seconds when pressed. When I was using the Uno I managed to find enough videos and guides online that I had everything working. Flip switch to power it on using a 9v battery, press push button and voila, message appeared on the LCD. I was super happy to get it first try.
Then I wanted to make the connections more permanent and try to slim it all down. So I ordered an Arduino Nano Every and a perfboard. I tried to wire everything exactly the same again and solder it all(it's not super pretty but I think it works). I don't think any of the wiring is a major issue since I now get an error when verifying my code with the Nano Every. The code is the exact same as what worked with the Uno. If you still need pics of the wiring let me know, but for now here's the code I'm working with:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C mylcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int x = 2;
int val = 0;
void setup() {
// put your setup code here, to run once:
mylcd.begin(16, 2);
mylcd.backlight();
pinMode(x, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
val = digitalRead(x);
if (val == 1) {
mylcd.setCursor(0, 0);
mylcd.print("Testing");
delay(5000);
mylcd.clear();
}
}
To be honest, some of those lines are complete nonsense to me but they did work. Any help would be greatly appreciated! Thanks!
Whoops, good point. Here's the error I get when verifying with the Nano Every:
C:\Users\jakes\AppData\Local\Temp\ccjoDvzc.ltrans0.ltrans.o: In function begin': C:\Users\jakes\OneDrive\Documents\Arduino\libraries\LiquidCrystal/I2CIO.cpp:63: undefined reference to TwoWire::requestFrom(unsigned char, unsigned char)'
collect2.exe: error: ld returned 1 exit status
Multiple libraries were found for "Wire.h"
Used: C:\Users\jakes\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\libraries\Wire
Not used: C:\Users\jakes\OneDrive\Documents\Arduino\libraries\Wire
exit status 1
If that means what I'm guessing, I tried File > Examples > LiquidCrystal >
I verified and uploaded both HelloWorld_4bit and HelloWorld_i2c seperately. HelloWorld_i2c gave me the same exact error as my code does when verifying. HelloWorld_4bit did not give me any error(same as when I ditch the i2c on my code) but displayed nothing on the LCD.
The LiquidCrystal_I2C library you are using has an incorrect call to requestFrom() in the Wire library (there is no overload for arguments of type unsigned char). That particular library (by fmalpartida, since it takes "Positive" in the constructor) is rather old and does not appear to have any current support.
That just eliminated the I2C, and is meant to drive the display directly from the pins of the arduino. Since you have an I2C display, that will not work.
Is there any reason the incorrect call to requestForm() wasn't any issue with the Arduino Uno? If this is an old library is there a new version I should try using instead(I can see them in the library manager but have no idea which ones would be old or more up to date)?
Ahh. Yet another oddball library that reuses a common name used by another, better known library. There's no such file in either the LiquidCrystal or LiquidCrystal_I2C libraries that I'm familiar with.
I would suggest deep sixing that library, erasing it from your memory, and trying something if not more standard, at least more widely used.
Save yourself all this library misery and use the Bill Perry's hd44780 library. It is available through the library manager, and is plug and play for i2c address and controller configuration.
Here's and example sketch showing how to use the class for the i2c backpack displays.
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h> // include i/o class header
hd44780_I2Cexp lcd; // declare lcd object: auto locate & config display for hd44780 chip
void setup()
{
// initialize LCD with number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD
lcd.print("Hello, World!");
}
void loop()
{
lcd.setCursor(0, 1);
lcd.print(millis() / 1000);
delay(1000);
}
If you have any issues, there is a diagnostic sketch available from the library
I2Cexp.ino.
I just finished up drawing my murder scene of a wiring job when I saw your post here and with a couple quick changes to my code it's all working perfectly now. Thank you so much to all who responded!!