Can you convert Serial code to I2C code?

I have a bit of code I'm using from a guide I'm following that is using a serial display but my display uses I2C instead.

Can you adapt it?

Sure. First I'll have to dig up a crystal ball. Then if you send enough money I can get started.

Don

floresta:
Sure. First I'll have to dig up a crystal ball. Then if you send enough money I can get started.

Don

Simple yes or no would do mate, not asking you to do it for me just asking if it can be done and possibly a example no where does it say heres my serial code now adapt it to I2C for me, FFS -_-

Simple yes or no would do mate

Ok yes it can be done.

possibly a example

Well you haven’t posted anything to convert but basically get an I2C library and use the lcd.print calls instead of the Serial.print calls.

Grumpy_Mike:
Ok yes it can be done.
Well you haven’t posted anything to convert but basically get an I2C library and use the lcd.print calls instead of the Serial.print calls.

Thank you that's perfect

TheSkunk:
Simple yes or no would do mate, not asking you to do it for me just asking if it can be done and possibly a example no where does it say heres my serial code now adapt it to I2C for me, FFS -_-

I'm sorry if I offended you but the second sentence in your OP, "Can you adapt it?", seems to ask precisely that.

Don

Grumpy_Mike:
Ok yes it can be done.
Well you haven’t posted anything to convert but basically get an I2C library and use the lcd.print calls instead of the Serial.print calls.

We know nothing about the h/w, s/w, and application involved.
There was no mention of using asynchronous serial or using a "LiquidCrystal" type API on a text based LCD.
For all we know it could an intelligent graphic display and the timing to switch to I2C would not work due to other timing requirements.

It could also be that original project used a SPI GLCD display and the OP purchased the I2C version instead.
Depending on the library involved, this might be as simple as changing the constructor to tell the library about the different interface.

We simply don't know enough about the h/w, and software involved to make any sort of estimation as to whether or not it could be done much less what it would involve.
Hence, Don's comment about needing a crystal ball.

TheSkunk,
you need to provide more details about what type of display was originally used vs what you are now trying to use as well as a bit of background on the existing code - like what it does, for us to be able to offer any information/advice.

--- bill

Wow, talk about making things complicated. How many more way our scenario can you come up with .

There was no mention of using asynchronous serial

When someone on this forum talks about serial they mean asynchronous serial, no need to throw in a long word here to underline how clever you are. Most people here would think that the serial they use is something different from asynchronous serial.

or using a "LiquidCrystal" type API on a text based LCD.

If you are using serial then you have a character based output, which calls for a character based replacement. Yes you can construct weird cases where this assumption is wrong, but come on.

Your response is one of the reasons people find electronics complex and are put off. Yes electronics can be complex but not as complex as you make out.

Stop trying to frighten people being ultra pedantic.

Grumpy_Mike:
When someone on this forum talks about serial they mean asynchronous serial, no need to throw in a long word here to underline how clever you are. Most people here would think that the serial they use is something different from asynchronous serial.

You are quite wrong. Clever has nothing to do with it.
The term “serial” isn’t always obvious.
I have seen quite a few threads over the years where people are confused about what “serial” means.
Some are confused about “serial” vs i2c or “serial” vs SPI and occasionally the difference between async serial logic levels.
i.e. inverted vs non inverted.
Some of this may come from the sloppy use of words Ebay listings that sometimes call i2c or SPI “serial” interfaces.

Over the years, especially recently, I have seen many more threads about switching a graphic LCD between SPI vs I2C than I have for switching between a async serial text LCD to an i2c based one.

Even if the OP is trying to switch from using an async serial based text LCD to an i2c based LCD it would not be as simple as changing Serial.print() calls to lcd.print() calls as you mentioned.
Often async serial based LCDs are intelligent and so the sketch code would need to deal with not only the different API of a different library (especially for initialization) but also the sketch code may be taking advantage of the intelligent controller to perform some specialized functionality, like custom characters, line scrolling, blinking characters, backlight dimming etc.
At a minimum the serial interface messages would need to be understood since it is likely certain combinations of Serial.print() messages would have to be removed and changed to API calls in the i2c library. i.e. to send commands like clear, home, cursor positioning, or the creation of custom characters.
Depending on what other features of the serial LCD was being used, it could be very difficult or impossible to do depending on the i2c based LCD used.

The OP gave us absolutely nothing to go on other than the words “serial display” and “i2c display”.
We really need more context as to what he actually has and is trying to do to be able to offer any sort of advice or recommendations.

— bill

And Mike, don't forget about all the Matrix Orbital intelligent serial displays.
Then there are the intelligent serial displays used for LCD Smartie.

We need more context as to what the OP was/is using and trying to accomplish.

--- bill

Given the OP said:-

TheSkunk:
Thank you that’s perfect

If it is not he will be back to ask again.