Author Topic: LCD troubles  (Read 3918 times)

atrueresistance

  • Newbie
  • *
  • Posts: 11
LCD troubles
« on: January 25, 2013, 11:17:15 am »
Hello I have the model A board digispark (rev b present) and am struggling to get an LCD module running with it. Programming wise I use the basic sketch digistump provided.
This is the module and controller http://www.ebay.com/itm/160943085721?redirect=mobile
My wiring as follows
  • Digi                    -                        LCD
  • P0 (SDA)     -   (4.7k ohm)       -    SDA
  • 5v                      -                        VIN
  • P2 (SCK)     -   (4.7k ohm)       -    SCL
  • GND                   -                        GND
This is all wired to a bread board. I took about 2ft of Ethernet cable and soldiered to a cut 4 pin female pin set to easily connect/disconnect the display. 
Here are some photos of my wiring
http://imgur.com/a/XQAVV
 When I plug it in I get square boxes on the first line like the tutorial suggests, but they never go away, I've tried adjusting the contrast on the back knob.
« Last Edit: January 26, 2013, 01:56:09 am by digistump »

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: LCD troubles
« Reply #1 on: January 25, 2013, 11:22:35 am »
The 4.7k pullups need to go between the data lines and the 5v, not in series with the data lines.


So:


Code: [Select]

          5v
           |
       4.7kohm
           |
SDA-----------P0


and the same for SCK as well.


You'll also want to make sure you have the correct I2C address

atrueresistance

  • Newbie
  • *
  • Posts: 11
Re: LCD troubles
« Reply #2 on: January 26, 2013, 10:27:50 am »
I have a question about some code and weird anomalies.

Basic LCD functions:
 
Code: [Select]
float inside_temp;
float outside_temp;
float target = 74.00;

//inside_temp and outside_temp are values from 2 ds18b20's
inside_temp = 70.70;
outside_temp = 70.81;

LCD works when using this code with it commented out like this.  Compiled size 5,928 bytes.

Code: [Select]
 
if(inside_temp < target){
    //create a limit so heater isn't crazy hot as 5 gallons takes a while to change temp
    // float limit = target + 1;
    // if(outside_temp > limit){
    //   digitalWrite(RELAY_PIN, LOW);
    //   lcd.print("OFF");
    // }
    // else{   
      digitalWrite(RELAY_PIN, HIGH);
      lcd.print("ON");
    // }
  }
  else{
    digitalWrite(RELAY_PIN, LOW);
    lcd.print("OFF");
  }

LCD also works with this code. Compiled size 5,590 bytes.
Code: [Select]
// if(inside_temp < target){
    //create a limit so heater isn't crazy hot as 5 gallons takes a while to change temp
    float limit = target + 1;
    if(outside_temp > limit){
      digitalWrite(RELAY_PIN, LOW);
      lcd.print("OFF");
    }
    else{   
      digitalWrite(RELAY_PIN, HIGH);
      lcd.print("ON");
    }
  // }
  // else{
  //   digitalWrite(RELAY_PIN, LOW);
  //   lcd.print("OFF");
  // }


LCD does NOT work when uncommented. Compiled size 5,992 bytes. All it does is sit there with the backlit on and no text. http://imgur.com/xPAzY0N,DdGdYoI

Code: [Select]
if(inside_temp < target){
    //create a limit so heater isn't crazy hot as 5 gallons takes a while to change temp
    float limit = target + 1;
    if(outside_temp > limit){
      digitalWrite(RELAY_PIN, LOW);
      lcd.print("OFF");
    }
    else{   
      digitalWrite(RELAY_PIN, HIGH);
      lcd.print("ON");
    }
  }
  else{
    digitalWrite(RELAY_PIN, LOW);
    lcd.print("OFF");
  }


I don't understand why this happens. Can I not structure code like this?
« Last Edit: January 28, 2013, 06:43:19 am by atrueresistance »

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: LCD troubles
« Reply #3 on: January 29, 2013, 06:51:47 pm »
I think the issue might be that the sketch is too big - which wouldn't make sense since 6010 bytes are available - but it might be worth a try to cut some bytes out of the sketch and see if it works.