i2c Vs SPI LCD connection

My aim is to connect a 4x20 LCD from Modtronix (LCD2S) to an Arduino. With respect to writing code, which is the simpler code to learn/implement. I2C or SPI? To a novice, they both look a little overwhelming.

Has anyone used this display? It would be great to learn what pins are on the Arduino are required and to tap into some sample code.

Any advice is welcome.

SPI is easier but neither is difficult.

I have some examples of using an SPI DAC and an I2C real-time
clock in the application hints at
http://wiblocks.luciani.org/NB1/NB1A-index.html

(* jcl *)


www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks
blog: http://luciani.org

Thanks (jcl). I will study the code on wiblocks.com for driving an LCD and try to implement it.

Both look fairly easy to me, but I've never tried either (don't have a need, yet).

From my research, though, I would always go with I2C - why?

  1. Needs minimum number of wires per device on the bus; SPI needs an enable line per device.
  2. I2C is faster (well, at least from what I've read) than SPI.
  3. I2C is addressable (rather than needing enable lines as mentioned).

In short, it just seems like I2C is the better option overall, unless the device you are using doesn't support it, of course.

:slight_smile:

I believe I2C is slower. IIRC it has a maximum rate of 400KHz.

SPI does use up at least one extra line. Sometimes more depending
on the device.

(* jcl *)

It appears the Modtronix LCD2S that I intend to use only operates with I2C or SPI. If I use I2C, do I need to connect the I2C Interrupt line?

If I go down the I2C path, I connect SDA to pin 4 of the Arduino, SCL connect to pin 5, (+5V and GND). Do I need the Interrupt line? So far the sample code I can find doesn't refer to the Interrupt. Any suggestions?

What does the manual say the display uses the interrupt for?
For an application that just writes to the display I wouldn't
think you would need it but I am not sure.

The SDA is on Analog pin 4. The SCL is on Analog pin 5. I don't have an
Arduino so I am not sure of the Arduino pin numbers :wink:

I did think of a downside to I2C on an 168/328 -- you lose two analog inputs :wink:

(* jcl *)


www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks
blog: http://luciani.org

I believe I2C is slower. IIRC it has a maximum rate of 400KHz.

Hmm - I guess you're right; not sure what I was thinking:

It looks like I am going to have to do more research on both of these; it seems my comment on SPI needing a pin for each slave device for select usage may be incorrect (?)...not sure now.

it seems my comment on SPI needing a pin for each slave device for select usage may be incorrect (?)...not sure now.

All of the SPI devices I have seen require one pin to select. You place the SCLK,
MOSI, MISO lines of all devices in parallel and enable one device at a time.
Since input and output are on separate lines an SPI device that requires both input
and output needs four line per device. For these devices I2C saves two
lines.

(* jcl *)


www: http://www.wiblocks.com
twitter: x.com
blog: http://luciani.org

The I2C interrupt line is only used to indicate keypad keypresses and is completely optional if you just periodically poll the LCD.

I've actually written code to interface with the Modtronix LCD2S via I2C on the Sanguino. Should work on the Arduino. The relevant code is in the ModtronixLCD2S.[ch] and AsyncTwi.[ch] files in the zip file at http://www.belfry.com/code/SanguinoMaster-LCD.zip