TinkerKit Tutorial: LCD: 04 – LCD Local (No Arduino)

Posted by Jack L on

LCD Lessons:
  1. Windows Installation Guide
  2. Introduction to LCD
  3. LCD Serial
  4. LCD Local (No Arduino)
  5. Arduino & 2 Wires
  6. TWI

    The LCD module can also be used by itself, without Arduino or TinkerKit! shield. That’s because it mounts the same microcontroller as the Arduino Leonardo; thanks to its micro-usb connector, it can be plugged straight into your computer and programmed from the software just like a regular Arduino Leonardo.

    If you didn’t do it already, download the TKLCD library. The TKLCD library is available here, once downloaded, place TKLCD in the libraries folder inside your sketchbook.

    How to install the library:

    • unzip the downloaded file
    • move the TKLCD folder inside the “libraries” folder, usually located in Documents\Arduino\libraries (if it’s not there, just create it)
    • close the Arduino software, if it’s open, then relaunch it
    • to verify the installation, open the software and from the top menu click on sketch->import library. You should be able to see the TKLCD element in the list

    In this tutorial we’re not using the serial port, for this reason we don’t have to upload the firmware. Let’s begin by connecting the LCD module with a micro USB cable, then open the Arduino software. In top menu, under Tools->Board select Arduino Leonardo.

    First of all we have to include all the libraries required by the LCD module: TKLCD, LiquidCrystal and Wire. The last two don’t need to be downloaded, they’re included in the Arduino software and are selectable just like the other libraries from Sketch->Import Library.

    Now we have to create a LCD object in the globals, like every other module. There are two different classes for the TinkerKit! module, we have to declare it as TKLCD_Serial or TKLCD_Local according if we are using it via serial or via USB.

    TKLCD_Local lcd = TKLCD_Local();
    Then we have to initialize it in the setup:
    lcd.begin();
    Let’s start by writing something on our LCD screen: inside the setup write
    lcd.print("Hello World!");

    Now load it into the module, you should see this on the LCD:

    Every time that we want to print something new on the screen, we have to “refresh” it with the clear() function. To write “Hello World!” but with the two words alternating every second on the screen, we have to type:

    lcd.clear();
    lcd.print("Hello");
    delay(1000);
     
    lcd.clear();
    lcd.print("World!");
    delay(1000);

    Load it into the module and you should see "Hello" and "World" fleshing.

    Now let’s use it to read the value of an input. Connect a thermistor to one of the connectors, then we’ll use the LCD screen to read its values. Don’t forget to include the normal TinkerKit! Library if you’re using modules other than the LCD. The name of the LCD ports are slightly different from the TinkerKit! shield; here the inputs have the prefix A and the outputs D. In our example we’re connecting the thermistor to the A1 port.

    TKThermistor therm(A1);
    Our loop function is now:
    //read the temperature sensor
    int temp = ldr.celsius();
     
    //print the values on the lcd
    lcd.clear();
    lcd.print("Temp: ")
    lcd.print(temp);
    delay(20);
    Now take a look at all the examples included in the library or read the dedicated space in the reference section to discover more functions.

    Share this post



    ← Older Post Newer Post →


    Leave a comment

    Please note, comments must be approved before they are published.