Teensy3.5 + LCD (16X2)

Status
Not open for further replies.

tutu

Member
I'm trying to use a Teensy3.5 with a LCD (WM-C1602M), but I just get the fist line with black squares and the second empty. It was working with my arduino. Do I need some resistor?


LCD doors sequence:

GND 5V GND D4 GND(constrast pin) D5 (4 in the center with nothing) D6 D7 D8 D29 D30 GND


CODE:

#include <LiquidCrystal.h>


char ch;
int Contrast = 15;

LiquidCrystal lcd(4, 5, 6, 7, 8, 29);

void setup(){

Serial.begin(9600);

lcd.begin(16, 2);

lcd.print("FIRST LINE");

}

void loop(){

lcd.setCursor(0, 1);

lcd.print("SECOND LINE");

}

void serialEvent(){

if (Serial.available()){

ch = Serial.read();
if (ch == 'A' && Contrast < 255)
{
Contrast = Contrast + 1;
}
if (ch == 'B' && Contrast > 0)
{
Contrast = Contrast - 1;
}
if (ch == 'N')
{
analogWrite(30, 28836);
}
if (ch == 'F')
{
analogWrite(30, 0);
}

Serial.println("Current contrast");
Serial.println(Contrast);
}
}
 
I'm trying to use a Teensy3.5 with a LCD (WM-C1602M), but I just get the fist line with black squares and the second empty. It was working with my arduino. Do I need some resistor?


LCD doors sequence:

GND 5V GND D4 GND(constrast pin) D5 (4 in the center with nothing) D6 D7 D8 D29 D30 GND

Most likely you will need to do level shifting, The LCD is expecting 5v input (because you connected the power line to 5v and not 3.3v). A brief glance at the datasheet shows this LCD needs 5v (some LCDs can run at either 3.3v or 5v, and assuming it doesn't use too much power, you would connect the 3.3v instead).

The 3.5 only puts out 3.3v on the data signal pins. The display won't see the 0/1 signal, and just reads 0. You will need to convert each of the data signals from 3.3v to 5v. You will need something like 12 pins shifted, so perhaps getting 3 74AHCT125's, or similar converters.

The 3.5 can read digital signals that are 3.4-5 volts, so if you had an input from the display, you don't need to shift it for input. However, the 3.6 and LC are not protected with 5 volt inputs, and you will likely fry the chip if more than 3.3v is applied to an input pin (BTDT). So, it is a good practice to do level shifting for inputs as well, in case you switch to a LC or 3.6 some day.

CODE:

#include <LiquidCrystal.h>

char ch;
int Contrast = 15;

Please use the '#' button in the reply to put CODE markers around your code. Otherwise, the forum software deletes all indentation, and converts things that look like smilies to graphics. Here is what your code looks like indented:

Code:
#include <LiquidCrystal.h>

char ch;
int Contrast = 15;

LiquidCrystal lcd(4, 5, 6, 7, 8, 29);

void setup(){
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.print("FIRST LINE");
}
 
Last edited:
Can I do it with resistors? Or use some other technique?

Can you do what with resistors? I'm not sure what you are asking.

If you meant level shifting, no you need more than just resistors, since you are going from 3.3v to 5v. If you were going from 5v to 3.3v, yes you could use resistors, since resistors can lower the current, but they don't add to the current. What you want is a couple of level shifters, such as the 74AHCT125:

It is probably simpler to change displays to use something that supports 3.3v directly, such as the various OLED displays that use SPI or I2C. It also reduces the pin count of what you have to connect. These have a little microprocessor on board that converts SPI or I2C to the display. Note, both SPI and I2C use fixed pins on the Teensy. Something like:

Here is a cheaper OLED display from ebay. Note, since these are i2c, you will need two 2.2K resistors, one going from pin 18 to 3.3v and the other going from pin 19 to 3.3v:

Or use a backpack that does the pin support using SPI or I2C:
 
Last edited:
Status
Not open for further replies.
Back
Top