Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

New Guy with LCD questions

Status
Not open for further replies.

animal

New Member
hey folks . I real new , very new to the Arduino world . I have been trying to make a tachometer for my lathe . it seems that all the projects I find to try to use are for the older LCD's without the backpack. I have the newer lcds & I cant for all my searching find how to change from a multi wire LCD to a 4 wire LCD (vcc,gnd,sda & scl )in a sketch .
can someone please point me in the direction where I can find that info
thanks
animal
 
Hi,

Sure what Pommie has suggested will work fine.

However to save yourself needlessly searching, when stuck for such program code, you first want to look in the Arduino main site, more info there than you can imagine including all the basic code parameters.

https://www.arduino.cc/reference/en/


Every I2C device has its own ID code and typically LCD I2C modules are set to 0x27 by default, and needs addressing as such in the program code.
However thats not always true or you may want to use other I2c devices as well.

This little bit of code from the web will just read the ID code from the I2C device / LCD once you have wired it up, always a good check.
 

Attachments

  • I2C_scanner.zip
    1.1 KB · Views: 212
Hi,

Sure what Pommie has suggested will work fine.

However to save yourself needlessly searching, when stuck for such program code, you first want to look in the Arduino main site, more info there than you can imagine including all the basic code parameters.

https://www.arduino.cc/reference/en/


Every I2C device has its own ID code and typically LCD I2C modules are set to 0x27 by default, and needs addressing as such in the program code.
However thats not always true or you may want to use other I2c devices as well.

This little bit of code from the web will just read the ID code from the I2C device / LCD once you have wired it up, always a good check.

I would agree, particularly as in my experience the LCD I2C modules aren't always set to 0x27 as they are 'supposed' to be. You can spend a LOT of time messing around, only to find the I2C address isn't what you thought it was. By setting them to different addresses you can have multiple LCD's easily connected to the same I2C bus, I played with four different ones one day (all with different size LCD's on them), just because I could :D
 
One problem I found with i2c LCDs is the speed. I had a 4x20 LCD and it took 80mS to update the display. This made it completely unusable for what I wanted - a scrolling menu system. They're great for static displays but don't try scrolling.

Mike.
 
One problem I found with i2c LCDs is the speed. I had a 4x20 LCD and it took 80mS to update the display. This made it completely unusable for what I wanted - a scrolling menu system. They're great for static displays but don't try scrolling.

To be fair, the LCD modules aren't very quick anyway (LCD's aren't), and the I2C adaptor simply converts from serial to parallel, and runs the LCD in the exact same way as a direct parallel connection.

If it's excessively slow then there's probably too many delays in the routines driving it, so it should be fairly easy to speed it up to just as fast as the standard parallel display.
 
thanks folks , I'll run the I2c scanner & see what it says. so how do I keep multiple LCD library's . can I save them to another name & then use the changed name in the sketch ?
thanks
animal
 
You only use one library and change the addresses of the various LCDs. At school now so can't check but I think they have solder pads to change the address.

Mike.
Just had a quick google and they appear to be labelled A0, A1 & A2.
 
I just uninstalled the Arduino IDE from my pc , dumped all my sample sketches & deleted the librarby's & then cleaned up the pc some.
then I reinstalled the most recent IDE & uncompressed it . I didn't go any further with it than that tonite will get back into it tomorrow . what I meant by
multiple library's was somehow I ended up with 3 LCD library's , so how do ya know which one ya need for a particular sketch ? should I have had those 3 LCD library's ? that's when I got frustrated & wiped everything thinkin I'll start fresh
thanks
animal
 
Does your backpack look like this?
I2C LCD.jpg

Mike.
 
The attached layouts might help . ..

S
 

Attachments

  • Arduino Uno Layout.jpg
    Arduino Uno Layout.jpg
    263.5 KB · Views: 224
  • Mega2560 Layout.png
    Mega2560 Layout.png
    386.1 KB · Views: 227
I just uninstalled the Arduino IDE from my pc , dumped all my sample sketches & deleted the librarby's & then cleaned up the pc some.
then I reinstalled the most recent IDE & uncompressed it . I didn't go any further with it than that tonite will get back into it tomorrow . what I meant by
multiple library's was somehow I ended up with 3 LCD library's , so how do ya know which one ya need for a particular sketch ? should I have had those 3 LCD library's ? that's when I got frustrated & wiped everything thinkin I'll start fresh
thanks
animal

Not sure why you have uninstalled etc, but things can seem very confusing when you first start, and afterwards :D

Be aware that uninstalling the Arduino ide does leave a lot of your data intact, though always best to play safe saving your sketches etc.

When reinstalling find the Windows Installer better than the Zip version as the Installer puts Arduino in to theWindows / Program Files folder and seems to install the USB routines better .

The Default Libraries folder contains the stardard 4/8 bit lcd rouines, but if you download and install another called LiquidCrystal_I2C then that should be fine as your sketch will also call for that library.

eg

For the standard lcd -

// include the library code:
#include <LiquidCrystal.h>


For a I2C lcd

#include <Wire.h>
#include <LCDI2C.h>

If you find that someone has a library but with the same name as another lcd routine, then you first need to rename your original lcd library , and then install the new one.
 
yea , my back pack looks like that one it's just the 8574t so from what I read & the scanner told me is 0x27 . that 's exactly why I did the uninstall & reinstall , cause things got confusing . so if I have a library lets say XYZ.lib but it wont work with my XYZ board & I find a new library that works & it is also called XYZ.lib
I should save it to a new mane say XYZ1.lib & the include XYZ1.lib in my sketch ? does that make sense
thanks animal
 
First use File Explorer to look in the Arduino / Libraries and either ReName or Delete your original XYZ.lib if its stil there after your reinstall.

Once that is out of the way, then you can add in your new XYZ.lib , either by unzipping and directly copying its folder into the Arduino / Libraries
or much easier, using the inbuilt tool which allows you to just select the .zip file you downloaded for the library.

Not good to try and allocate a new library name as it will likey cause a problem with the rest of its code.

000122.jpg
 
thanks , I'll dive back into this later this afternoon . I just put a treadmill motor on my metal lathe , I'm using a pic pwm controller I got from a guy in one of teh machine tool forums . what I plan to get to is a bit mote advanced motor speed control the the one I have , so my Tach project seemed like a place to start
thanks again for all your guys help
animal
 
You didn’t say what error codes.
I may have overlooked something, but try this.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define sensor 9
#define start 12
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
int delay1()
{
//unsigned int long k;
int i,j;
unsigned int count=0;
for(i=0;i<1000;i++)
{
for(j=0;j<1000;j++)
{
if(digitalRead(sensor))
{
count++;
while(digitalRead(sensor));
}
}
}
return count;
}
void setup()
{
pinMode(sensor, INPUT);
pinMode(start, INPUT);
pinMode(2, OUTPUT);
lcd.begin();
lcd.backlight();
lcd.print(" Tachometer");
delay(2000);
digitalWrite(start, HIGH);
}
void loop()
{
unsigned int time=0,RPM=0;
lcd.clear();
lcd.print(" Please Press ");
lcd.setCursor(0,1);
lcd.print("Button to Start ");
while(digitalRead(start));
lcd.clear();
lcd.print("Reading RPM.....");
time=delay1();
lcd.clear();
lcd.print("Please Wait.....");
RPM=(time*12)/3;
delay(2000);
lcd.clear();
lcd.print("RPM=");
lcd.print(RPM);
delay(5000);
}
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top