Go Down

Topic: i2c lcd on promicro (leonardo) wont work? (Read 89 times) previous topic - next topic

ManusH

good day. Im using pro micro bords and want to run 16x2 i2c lcd. i ran i2c scanner and find the address as 0x27. so the controler see the lcd, but it does not display any thing. sda conected to pin 2 and scl to pin 3. changed contrast......does any one know wat i coukld be missing?

the code


#include <Wire.h>

#include <max6675.h>
#include <LiquidCrystal_I2C.h>

 
LiquidCrystal_I2C lcd(0x27,16,2);

//other large lcd is address 3F

     
const int sensorMin = 0;     // sensor minimum
const int sensorMax = 1023;   // sensor maximum   
int potPin = A3;
int thermoDO = 8;
int thermoCS = 7;
int thermoCLK = 6;
int heater = 9;
int    LiquidCrystal_I2C;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
   
void setup()
{

 lcd.begin(16,2);
  pinMode(heater, OUTPUT);
  Serial.begin(9600);
 
  pinMode( potPin,INPUT);
 
 
  Serial.println("MAX6675 test");
  // wait for MAX chip to stabilize
  delay(500);
}
   
void loop()
{
     
  //temp read start
  int settemp = analogRead(potPin);
  delay (100);
  settemp = map(settemp, 0, 1023, 40, 95);
  //Serial.println(settemp);
  Serial.print("SET ");
  Serial.print(settemp);
  lcd.setCursor (0,0); // set the cursor to 3,0
  lcd.print ("SET ");
  if (settemp > 100) // if the temperature exceeds your chosen settemp
  {
    lcd.clear(); 
    //lcd.setCursor (5,0);
    //lcd.print ('');  //dont print any spaces
    lcd.setCursor (0,0); // set the cursor to 3,0
    lcd.print ("SET ");
  }
  else if (settemp < 10)
  {
    //lcd.setCursor (7,0);
    lcd.print ('  ');  // print 2 space
  }
  else
  {
    //lcd.setCursor (6,0);
    lcd.print (' ');  // print 1 spaces
  }
  //if  over hundred go to 5
  lcd.print (settemp);
 
  delay (100); // wait for the lcd to refresh every 250 milliseconds
  int currenttemperature = thermocouple.readCelsius();
  lcd.setCursor (0,1); // set the cursor to 3,0
  lcd.print ("TEMP ");
  if (currenttemperature > 100) // if the temperature exceeds your chosen settemp
  {
    //lcd.setCursor (5,0);
    //lcd.print ('');  //dont print any spaces
   lcd.clear(); 
    lcd.setCursor (0,1); // set the cursor to 3,0
  lcd.print ("TEMP ");
  }
  else if (currenttemperature < 10)
  {
    //lcd.setCursor (7,0);
    lcd.print ('  ');  // print 2 space
  }
  else
  {
    //lcd.setCursor (6,0);
    lcd.print (' ');  // print 1 spaces
  }
  //if  over hundred go to 5
  lcd.print (currenttemperature);
  delay (100);

  Serial.print("   C = ");
  Serial.println(currenttemperature);

  if(currenttemperature < settemp)
  {
    digitalWrite(heater, HIGH);
  }
  else
  {
    digitalWrite(heater, LOW);
    Serial.println("heater off");
  }

  if(currenttemperature == 0)
  {
    digitalWrite(heater, LOW);
    Serial.println("faulty thermocouple");
    lcd.clear(); 
  }
 
  delay(500);
 
 
 

}





im new at this so the code may also be lacking. did run on pro mini before and worked fine.

david_prentice

First off.   Please edit your post to show code in a CODE window.

If your program works on a Pro Mini,  it should work on a Pro Micro.   Make sure that you wire the MAX6675 to the same digital pin numbers.   And the same LCD to the SDA, SCL pins.

Common problem with "LiquidCrystal_I2C" is that there are several libraries with that name.

Life is much safer with the "hd44780" library.

But as I said.   If it works with ProMini it should work with ProMicro.

David.

Go Up