i am a new user, so i used an example to check how my liquid crystal screen (2x16) works. (https://build.particle.io/libs/LiquidCrystal/0.0.3/tab/example/Spark-HelloSparky.cpp)
it compiles just fine and i can flash it to the particle, but all the screen shows is a mess of ??? and 0000s. what’s wrong with it?
Welcome. It's kind of hard to recommend anything without knowing more about your setup. For example, what screen are you using? Do you have a link to it? Is the screen I2C, SPI, or parallel? How is that screen hooked up to your particle device (and which type of particle device)?
i’m using a particle photon
as for the screen, i have no idea what it is because it didn’t actually say
https://bit.ly/2K4HEcT
and it’s hooked to the particle using https://blog.jongallant.com/2015/10/particle-photon-lcd-setup/
That link for the screen is a parallel setup; the pin labels are that of a standard parallel-type input. I don’t read Chinese so I’ll just assume it works like any other 16x2 character LCD. My first thought is there is that there’s a wiring problem. Check your wiring matches this line in the code LiquidCrystal lcd(D0, D1, D2, D3, D4, D5);
. My second thought is that the character set isn’t english… but I would check the wiring first. I know some screens can operate with either 4 or 8 input wires. The code snippet above references 6 input signals. I’ve never used that library and I don’t have a screen like that to test with. I have a 20x4 screen that I just got recently but I plan to use I2C to communicate.
Anyone else have more pertinent thoughts?
@ninjatill, I agree with your comments. The product description doesn’t even mention a 4-bit configuration and I share your suspicion of the character set. @phoenixwitch, can you share a picture of your setup?
Like @ninjatill, I tend to use I2C 1602 or 2004 displays or smart LCD units from Digole which support I2C, SPI or Serial interfaces.
umm… how do you check if it matches? like particle D0 to lcd D0 or something else? because the new setup i tried to follow
doesn’t do that (and right now i can’t even get the backlight to turn on oh god)
Provide a hi-res photo of the pin markings of the display and double check if the names match the names intended for your wiring.
Also be sure to properly solder the pins on the display.
It’s usually better to provide a photo of your actual setup rather than a link to some project your setup may or may not resemble.
And that image should be hi-res and clear to follow the wiring (color coded wires, fully visible, …)
Seeing as nothing is, or has been, soldered to the screen, how exactly did you connect it?
That's never a good starting point with any project - especially not once you experience problems.
Even if it starts off OK, you should never let it get into a mess, no matter what
@phoenixwitch Here is a real datasheet for a 16x2 LCD display sold on Adafruit. On page 5 (labeled 5 but actually 4th page in file) shows a very good explanation of what all the pins actually do. On page 6, there is a good explanation of 4-bit vs 8-bit mode. The datasheet is always the best starting point for any project… not a random blog without any explanation on pin hookups.
So you need to determine if your display can handle 4-bit mode. The liquidcrystall.cpp file explicitly states that it will always use 4-bit mode as you can see in this comment // Always 4-bit mode, don't waste pins!
. In the datasheet linked above, it states that in 4-bit mode, only D4-D7 are used for data bus inputs. The other 2-3 pins specified in the the HelloSparky example are for the RS, RW and E pins on the display. The default example initializer LiquidCrystal lcd(D0, D1, D2, D3, D4, D5);
only specifies an overload of 6 pins. That default leaves out a connection to RW which means you have to tie RW to ground and you will only be doing write operations, not read. Also in the HelloSparky example, in the comments it explicitly lays out the assumed/default photon to LCD connections:
The circuit:
* LCD RS pin to digital pin D0
* LCD EN pin to digital pin D1
* LCD D4 pin to digital pin D2
* LCD D5 pin to digital pin D3
* LCD D6 pin to digital pin D4
* LCD D7 pin to digital pin D5
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
* connect R/W (pin 5) to ground
And yes, a photo of the display was nice, but your wiring is the most important thing we needed to see to help.
Examples like this often don’t include the read operations as these displays are typically 5V and so that could damage the 3.3V pins on something like a Pi or Photon. Most of these types of display are quite happy with 3.3V signaling to write to them but that isn’t universally true.
thanks for helping me! turns out it wasn’t any wiring or coding problem – the screen i was using was simply malfunctioning due to bad connections. i got another and it’s working now.