-
Notifications
You must be signed in to change notification settings - Fork 448
Replies: 2 comments · 8 replies
-
You'd need to tell the lcd1 object to use Wire1 instead of Wire. Maybe the LiquidCrystal_I2C class has a method to set that, or a constructor option? |
Beta Was this translation helpful? Give feedback.
All reactions
-
Assuming I've found the right repo for the one you're using, there was a pull request to add support for Wire1, but it still hasn't been accepted: johnrickman/LiquidCrystal_I2C#16 However, you could fork your own version and maybe merge that pull request, or you could just download the library and either install your own copy, then edit it, or just place the library files in your project folder, exit the IDE and then start it up again. Then change the include from #include <LiquidCrystal_I2C.h> to #include "LiquidCrystal_I2C.h" (quotes for a local path instead of angle brackets). You can then edit the .h and .cpp files to get it to do what you want. Maybe add a pointer to the wire object to use to the class, and add an optional parameter to specify that, in the constructor, then look through the code for references to Wire and change them to use that pointer instead. |
Beta Was this translation helpful? Give feedback.
All reactions
-
Github can be confusing to navigate. Parts of it still baffle me too. Start from the page for the pull request: @Pigeo gives a link to a commit: On the right of the page, fairly near the top, you'll see a button labelled "Browse files". That takes you to: There you will see a button labelled "Code", to the right of the middle (depending on zoom level etc), fairly near the top. Click that then click "Download ZIP", at the bottom of the box that appears. That gets you the main .h and .cpp plus a folder of example sketches to use them with. I haven't read it properly, but I see he's added this member function to specify the wire object to use:
You could either do the same as before, copying the .h and .cpp into your project folder and changing the include path to use quotes, where needed, or make a backup copy of the library you had before, somewhere outside your Arduino\libraries folder, then paste in the contents of the folder inside the zip, to overwrite those files with the ones from the commit. Personally, I think I'd keep them with the project since it's not an official release. That will stop you accidentally overwriting them with a different version of the library. |
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you for the excellent navigation. Any advise make me pleased. Below is examples/HelloWorld/HelloWorld.ino //YWROBOT #define ARDUINO_SAM_DUE LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address to 0x27 for a 16 chars and 2 line display void setup() // Turn on the blacklight and print a message. void loop() Below is Compilation error FQBN: arduino:sam:arduino_due_x_dbg Detecting libraries used... 次のフォルダのライブラリWireバージョン1.0を使用中:C:\Users\pd5y-\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\libraries\Wire Compilation error: no matching function for call to 'LiquidCrystal_I2C::begin(TwoWire&)' |
Beta Was this translation helpful? Give feedback.
All reactions
-
You're welcome. It seems he made changes to the library and forgot to update that example. You'll need to use init(Wire1) instead of begin(Wire1). Here's the relevant section from the .cpp file: He added the init() function to allow specifying the wire object to use (class TwoWire) and as you can see, that calls init_priv() which calls begin(), so you need to use lcd.init(Wire1) instead of lcd.begin(). Given that the example seems to be out of date, I wouldn't worry too much if you still can't get it to work. It's probably better to read it then make changes to the code you started with instead.
|
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you for the useful advice. According to your excellent advice, I changed from lcd.begin(Wire1) to lcd.init(Wire1). So I could compile HellowWorld.ino, assuming the target device is Arduino Due. Any adice make me pleased. Also I attached the zip of HelloWorld.ino,LiquidCrystal_I2C Library.h and LiquidCrystal_I2C Library.cpp. The connections are below, Sorce code(HelloWorld.ino) is below, //YWROBOT #include "LiquidCrystal_I2C.h" LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address to 0x27 for a 16 chars and 2 line display void setup() // I2C pin Setting // Turn on the blacklight and print a message. void loop() Comliler output, when the firmware of HelloWorld.ino is written into pico W successfully. FQBN: rp2040:rp2040:rpipicow Detecting libraries used... 次のフォルダのライブラリWireバージョン1.0を使用中:C:\Users\pd5y-\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\4.4.1\libraries\Wire |
Beta Was this translation helpful? Give feedback.
All reactions
-
The picture looks like the contrast is set wrong. This type of LCD has one pin which needs an analog voltage applied to it between 0V and the supply voltage of the display (e.g. 3.3V or 5V). Usually, the ideal voltage is close to ground (0V) and often just connecting that pin to ground gets you quite close to a good setting. Some displays have a preset potentiometer (also known as a trim pot) to let you adjust that voltage. Others need one connecting. 5k or 10k is normally suitable. The middle pin of the potentiometer goes to the contrast pin, one of the outside ones goes to ground and the other one goes to the supply voltage pin on the display - either way around works. |
Beta Was this translation helpful? Give feedback.
-
This is the first Question for arduino-pico Discussion. Below code is for SunFounder I2C LCD2004 (20x4 line) connected to I2C0/I2C1 pin of pico W.
"Code for I2C0" works well. LCD2004 shows the characters, namely
1st line: Hellow World !!
2ne line: How are you ?
3rd line: What is your name ?
4th line: How old are you ?
But "Code for I2C1" does not works well. Although I can compile "Code for I2C1" without warning or error, I cannot see any character on LCD2004 display.
I would like to show characters like "Code for I2C0" on LCD2004 display, which is connected to SDA and SCL of I2C1 of pico W.
Please advise me.
How do you modify "Code for I2C1" ?
Any advise make me pleased.
// Code for I2C0 ---------------------------------------------------------
//SunFounder I2C LCD2004 (20x4 line) for I2C0 pin of pico W
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27
void setup()
{
// I2C pin set
Wire.setSDA(16); // 21pin(pico W): GP16 I2C0 SDA
Wire.setSCL(17); // 22pin(pico W): GP17 I2C0 SCL
Wire.begin();
lcd.backlight();
}
void loop()
{
lcd.setCursor(0,0); //1st line
lcd.print ("Hellow World !!");
lcd.setCursor (0, 1); //2nd line
lcd.print ("How are you ?");
lcd.setCursor (0,2); //3rd line
lcd.print ("What is your name ?");
lcd.setCursor (0,3); //4th line
lcd.print ("How old are you ?");
}
/*
// Code for I2C1 ---------------------------------------------------------
//SunFounder I2C LCD2004 (20x4 line) for I2C1 pin of pico W
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd1(0x27,20,4); // set the LCD address to 0x27
void setup()
{
// I2C pin set
Wire1.setSDA(14); // 19pin: GP14 I2C1 SDA
Wire1.setSCL(15); // 20pin: GP15 I2C1 SCL
Wire1.begin();
lcd1.init();
lcd1.backlight();
}
void loop()
{
lcd1.setCursor(0,0); //1st line
lcd1.print ("Hellow World !!");
lcd1.setCursor (0, 1); //2nd line
lcd1.print ("How are you ?");
lcd1.setCursor (0,2); //3rd line
lcd1.print ("What is your name ?");
lcd1.setCursor (0,3); //4th line
lcd1.print ("How old are you ?");
}
*/
Beta Was this translation helpful? Give feedback.
All reactions