Arduino Liquid Crystal - ATtiny1604 - megaTinyCore

Just some notes about what I learned today in the hope of helping others.

I wanted to build a battery powered device (gadget geo cache) and wanted to use one of these really cheap 2 x 16 character LCD displays.

I have a bunch of ‘spare’ pins on my target device and was keen not to hook an IC2 adapter to save power.

Starting with the basic documentation at https://docs.arduino.cc/learn/electronics/lcd-displays/ I hooked up my device.

The ATtiny1604 pins PA4-PA5 then PB3-PB2 all form a nice almost lined up set of pins against the display DB7-DB4 - (OK a gap) then E and RS.

I had though the E and RS pins needed to be SPI pins on the device but not so.

My final wiring hook up was

ATtiny1604 Arduino Ref LCD display

PA4 0 RS

PA5 1 EN

PA6 2 D4

PA7 3 D5

PB3 4 D6

PB2 5 D7

(and the other LCD pins for power and contrast)

The pertinent lines of code:

const int rs = 0, en = 1, d4 = 2, d5 = 3, d6 = 4, d7 = 5;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

The reason why I’m posting this is I wasted the afternoon trying to work out what was going wrong.

It turns out I had a stray Serial.begin(BAUD); statement in the code and this stuffed up PB2 - you can swap the UART to use pins to PA1, PA2 but I plan to use SendOnlySoftwareSerial.h to dump debug TTY to another pin (hey maybe even PA0 {requires HV programmer}).

I was struggling to find evidence that the megaTinyCore device wrappers could do what I wanted and I guess this validates the concept.

Enjoy…

BTW - if you need to output the degree symbol on the LCD display, you can use lcd.print(char(223)), this saves having to create a custom character.