-
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. 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. Please advise me. Any advise make me pleased. // Code for I2C0 --------------------------------------------------------- LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 void setup()
lcd.backlight(); void loop() /* LiquidCrystal_I2C lcd1(0x27,20,4); // set the LCD address to 0x27 void setup() lcd1.init(); void loop() */ |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 18 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.
-
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.
-
Okay, so what happens when you change Wire to Wire1, and change the pins for Occasionally, a problem can be caused by bad soldering on a header pin. Since you have it on a breadboard, you could try other pairs of pins that are valid for I2C1 too. I can see six possible locations on the pinout: |
Beta Was this translation helpful? Give feedback.
-
Please mark this as the accepted answer, if it solved your original problem. To summarise, the solution was to take an existing library that worked on I2C0, import the contents into your sketch and make changes to allow I2C1 to be used as an alternative. This was simplified a bit by using a pull request for the library you were using which hadn't yet been accepted, but it needed a couple more changes:
The rest of the details were discussed between us in the comments above. |
Beta Was this translation helpful? Give feedback.
You're welcome. I'm glad it's working for you.