It's possible to use a 20x4 display with SPI?

Hello, I have a project with an UNO and now I'd like (needed) to use also the A4 A5, which are busy with I2C
I've seen that an 128x64 dot display can work (in fact I used, but still don't know how to write on it) with SPI, and then I noticed that my 20x4 also has these pins RS, R/W E.
I use now a MEGA for test and have this

#include <SPI.h>
// define spi bus pins
#define SLAVESELECT 53
#define SPICLOCK 52
#define DATAOUT 51      //MOSI
#define DATAIN 50       //MISO

I think's it ok, but of course, it doesn't work, as I came here for help .
Can you please help me? If only let me know if it can work or not, I think it's ok, as with google have found nothing useful for this.
thank you

Why not use i2c for the LCD as well?
For about $1 USD on Ebay you can get a i2c to hd44780 backpack which allows using the lcd with I2C rather than direct pins.

Alternatively if you want to make your own backpack, you could use use a shift register.
There are several ways to wire it up, depending on how many pins you want to use.
If you google around you will find lots of information how to do this including libraries.

If you want a pre-made solution that works with either i2c or SPI, you could buy the lcd backpack #292 from Adafruit, which supports both I2C & "SPI"
and includes a library.

--- bill

I used the I2C board, but on the UNO it needs A4&A45, and now I also need them for a new pair of analog input.
is this? looks it can work, I'll buy and will check, Thank you very much :slight_smile:

Your Uno has got Analog pins A0-A3. A4, A5 are best used for I2C.

A bus means just that. You have multiple passengers on a bus. You can put many different I2C devices on the I2C bus at once.

You can buy a 20x4 with an I2C backpack for less money than the Adafruit adapter.

If you really want a 128x64 GLCD, look at displays with a ST7920 chip.
These run on SPI bus. You still have plenty of spare Analog and Digital pins on a Uno.

Write down your "pin budget" for a new project. Then ask here. You can generally get everything onto a Uno.

David.

Thank you, I saw one, is REMOVED, SORRY**** but I'm not sure because the back board looks the same I have only for I2c, but below they indicate can be used for SPI using the bridge. I already have the 128x64 and the 20x4, the first i just received today and had still no time to learn how to write letters, I only used the arduino or library examples with spi. Currently i use 4 analog inputs and need the two other, but as everything is finished, there is no room enough for a mega now

You have posted a dead link (you cannot link to banggood - they do not want our business!).

Do not use a UNO for a serious project! It is essentially for experimentation. If you use a Nano, you have A6 and A7 available as analog inputs with no digital functionality, so you can use A4 and A5 for I2C. If you don't need USB, you use a Pro Mini.

david_prentice:
You can buy a 20x4 with an I2C backpack for less money than the Adafruit adapter.

Yeah!


antber:
Currently I use 4 analog inputs and need the two other, but as everything is finished, there is no room enough for a mega now

So you haven't an operating prototype, buy you think your project is "finished".

You must be joking! Not very smart! :roll_eyes:

Paul__B:
You have posted a dead link (you cannot link to banggood)

Removed, sorry.

This is the fifth "project" for the company I work for, they do not want to spend much money, the first, which with I learnt (with great help of a former companion, I was electronic technician until 12 years ago) and then we tried to use a nano in the finished version, but all of them are on trash, because I (we) had a LOT of problems with them, malfunction, hangs, erratic behaviour, sometimes were not detected by to any pc to upload code.....the 5 or 6 I tested, only the cheapest (3€) was the more reliable, but I didn't trust them anymore and I prefered using uno's and/or mega's, all of them working without problem since october.
For a serious work I never would use an arduino, professional PLC (omron, siemens...)are the best and more reliable option, but due to their price, for bosses "is less reliable" xD.

It was on service when system to be controlled was modified three days after installation xD (added two water filter), now there are (will be) 2 extra pressure sense, I only need that display shows these new 2 data,

I'll buy one of this back, I found the original adafruit in the country where I live for about 8 €. Thank you all, when (if) solved I'll let you know