Go Down

Topic: Is my communication section of board dead? (Read 150 times) previous topic - next topic

OldSteve

Quote
and if you dont have the liquidcrystal I2c library it is on this page: https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
That's a different I2C LCD library to the one I'm using, so I can't write any test code for you.

Assuming that library is compatible with your LCD, the "Hello World" example provided with the library should work:-
Code: [Select]
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup()
{
// initialize the LCD
lcd.begin();

// Turn on the blacklight and print a message.
lcd.backlight();
lcd.print("Hello, world!");
}

void loop()
{
// Do nothing here...
}


I can't put in any more time right now. It's almost 11pm here, and I have a few things to do before bed.

Hopefully someone else will come along to help if you have more problems.

The idea is to get the LCD working next, then some simple code that reads the temperature sensor and prints the result to the LCD or serial monitor, then it's worth taking another look at your entire program.

Good luck. :)
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

programmer2005

I bought the lcd with a kit from amazon it is a sunfounder one and i got the library from the link in the earlier post.

OldSteve

#17
Jul 07, 2016, 02:56 pm Last Edit: Jul 07, 2016, 02:56 pm by OldSteve
I bought the lcd with a kit from amazon it is a sunfounder one and i got the library from the link in the earlier post.
If the code above doesn't work, the next thing to do is double-check your LCD's I2C address, in case it's not 0x27.

The sketch below will sniff out the I2C address and print it to the serial monitor. If different, he address must be put into the LCD constructor in place of 0x27:-
Code: [Select]
// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>

void setup()
{
    Wire.begin();

    Serial.begin(9600);
    while (!Serial);             // Leonardo: wait for serial monitor
    Serial.println("\nI2C Scanner");
}

void loop()
{
    byte error, address;
    int nDevices;

    Serial.println("Scanning...");

    nDevices = 0;
    for (address = 1; address < 127; address++ )
    {
        // The i2c_scanner uses the return value of
        // the Write.endTransmisstion to see if
        // a device did acknowledge to the address.
        Wire.beginTransmission(address);
        error = Wire.endTransmission();

        if (error == 0)
        {
            Serial.print("I2C device found at address 0x");
            if (address < 16)
                Serial.print("0");
            Serial.print(address, HEX);
            Serial.println("  !");

            nDevices++;
        }
        else if (error == 4)
        {
            Serial.print("Unknow error at address 0x");
            if (address < 16)
                Serial.print("0");
            Serial.println(address, HEX);
        }
    }
    if (nDevices == 0)
        Serial.println("No I2C devices found\n");
    else
        Serial.println("done\n");

    delay(5000);           // wait 5 seconds for next scan
}


Now I'm off to bed.
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy