mattgadient.com

Arudino workaround: backslash (\) shows on LiquidCrystal as the Yen symbol

I was putting together an “I’m alive” indicator on the Arduino-connected LiquidCrystal display, intended to rotate through |, /, -, \ repeatedly.

Problem was that instead of "\" I was getting "¥" .

Turns out that #92 in the character map on this LiquidCrystal display has that Yen (¥) character instead of the backslash.

In any case, the route I chose to get a backslash character was to make a custom character. The one I created looked like the image below.

Arduino custom backslash

Someone has created a fantastic little generator at https://omerk.github.io/lcdchargen/ if you want to make it look different. If you’d like to do the same thing, the code looks something like this:

byte customBackslash[8] = {
  0b00000,
  0b10000,
  0b01000,
  0b00100,
  0b00010,
  0b00001,
  0b00000,
  0b00000
};

void setup() {

  //I'll assume you have other stuff setting up the LCD here.
  
  //This line is just done during setup. I've set it as #7
  //(value should be between 0-7).
  lcd.createChar(7, customBackslash);
   
  //I'll now draw it in the bottom-right corner of my 20x4 display.
  //Obviously move it
  //to a different function if you want to change it on the go.
  lcd.setCursor(19, 3); //put it on line 3, column 19.
  lcd.write(byte(7)); //print our custom char backslash
   
}

 

As I mentioned, I stored it in #7 (last spot). The reason is because I use LcdBarGraphX which takes up #0-#4. If you use something else which creates custom characters and may fill those spots, you may want to see where it locates them. If you don’t use anything else and this is the only custom character, you could change lcd.createChar and lcd.write from #7 to #0 if you’d prefer.

Hopefully if you were in the same boat, this will get you going.  That said, if you have a more simple (or better) solution, feel free to leave a comment below!

2 Comments

 | Leave a Comment
  1. Great information it was very benefical thanks a lot

  2. thanks for the informative post

Leave a Comment

You can use an alias and fake email. However, if you choose to use a real email, "gravatars" are supported. You can check the privacy policy for more details.

To reduce spam, I manually approve all comments, so don't panic if your comment doesn't show up immediately.