Showing posts with label LCD. Show all posts
Showing posts with label LCD. Show all posts

Friday, April 7, 2017

Arduino_LCD_TFT_SDcard_shield_breakout

Using a Arduino TFT LCD shield in your project has some disadvantages.
1) The LCD TFT and SDcard occupy most of the IO pins on an Arduino Uno.
2) The IO pins are not easy accessible to connect other hardware.
This blogpost describes how i solved this second issue.
When using the shield with the LCD TFT the SDcard fee IO pins are :


  • A5 Analog5
  • D0 RX
  • D1 TX

  • D0 and D1 are also used for serial communication over USB but can be used if the Arduino is used standalone.
    For interfacing i also wanted access to GND, +5V and 3V3.
    I used some colored cables with a female Dupont connectors on one side. Male connectors can easy give short circuit if not in use, so i used female.
    You can easy create them from cutting a long Dupont Cables in two parts.
    I put them trough heat shrink tube and soldered them on my LCD TFT shield.
    You can use any color scheme, but Black for GND  and Red for the Power can give less confusion in your projects. I used this colors:
    3V3Orange
    +5VRed
    GNDBlack
    A5 Analog5Brown
    D0 RXGreen
    D1 TXYellow
    After soldering and arranging the cables i heated heat shrink tube.
    The female Dupont connectors are available to interface your project.
    As there are some differences between the shields i do not provide a script to display the analog signal on the TFT LCD for testing. Better use the Arduino program below that sends the Analog signal A5 to the serial (USB) port.

    /* 2016 Analog A5 JanJeronimus
    Get Analog 5 value every second
    Writes time [ uptime millis() ]  , 
     analog gas sensor value to the serial port
    */

    const int PinA5 = A5 ; //Connect Arduino analog A5 pin to sensor

    int val = 0;     // variable to store the Digital read value

    void setup()
    {
    Serial.begin(9600); //Initialize serial port - 9600 bps
    }

    void loop()
    {
    Serial.print( millis() ) ;
    Serial.print( " ,  " ) ;
    Serial.println( analogRead(PinA5) );
    delay(1000); // Print value every 1 sec.
    }

    On codebender :





    Monday, August 29, 2016

    Arduino_Shield_TFT_LCD_MCUFriend2.2

    On the arduino forum ( https://forum.arduino.cc/index.php?topic=366304.0 ) is a long discussion about MCDfriends TFT LCD displays
    There are different 2.4 TFT LCD MCU friends displays http://domoticx.com/arduino-shield-2-4-tft-lcd-touch/
    In this blog you find are pictures of the shield LCD shield i wanted to test.

    Warning:

    With some of the boards the USB B-type port on the Arduino Uno R3 is taller then the headers. As a result, many shields, including this one can contact the metal shielding of the USB port, causing damage. The simplest way to avoid this is to place a piece of electrical tape, or other tape, on top of the USB port to insulate it. ( Source : http://www.xcluma.com/how-to-use-2.4inch-tft-lcd-mcufriend )


    My shield has no connections or parts where the USB port is located therefore i did not insulate it.
    My shield has also an SD card reader that i tested earlier .
    On codebender.com i found a working Arduino to read info from the TFT LCD shields

    I cloned the program , it worked for my shield :
    Serial Monitor (to read the info)

    This is the result i found on the Serial Monitor when running it with my 2.4 LCD MCUFriend shield

    Read Registers on MCUFRIEND UNO shield
    controllers either read as single 16-bit
    e.g. the ID is at readReg(0)
    or as a sequence of 8-bit values
    in special locations (first is dummy)

    reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
    reg(0x0004) 00 00 00 00 Manufacturer ID
    reg(0x0009) 00 00 61 00 00 Status Register
    reg(0x0061) 00 00 RDID1 HX8347-G
    reg(0x0062) 00 00 RDID2 HX8347-G
    reg(0x0063) 00 00 RDID3 HX8347-G
    reg(0x0064) 00 00 RDID1 HX8347-A
    reg(0x0065) 00 00 RDID2 HX8347-A
    reg(0x0066) 00 00 RDID3 HX8347-A
    reg(0x0067) 00 00 RDID Himax HX8347-A
    reg(0x00B0) 00 00 RGB Interface Signal Control
    reg(0x00B4) 00 02 Inversion Control
    reg(0x00B6) 00 0A 82 27 04 Display Control
    reg(0x00B7) 00 06 Entry Mode Set
    reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
    reg(0x00C0) 00 21 00 00 00 00 Panel Control
    reg(0x00CC) 00 71 Panel Control
    reg(0x00D0) 00 00 00 Power Control
    reg(0x00D2) 00 00 00 03 03 NVM Read
    reg(0x00D3) 00 00 93 41 ILI9341, ILI9488
    reg(0x00DA) 00 00 RDID1
    reg(0x00DB) 00 00 RDID2
    reg(0x00DC) 00 00 RDID3
    reg(0x00EF) 00 03 80 02 02 02 ILI9327
    reg(0x00F2) 00 02 02 02 02 02 02 02 02 02 02 02 Adjust Control 2
    reg(0x00F6) 00 01 00 00 Interface Control

    Pin layput

    Shield pins with corresponding Arduino pins

    LCD_D2   - Arduino Digital 2
    LCD_D3   - Arduino Digital 3
    LCD_D4   - Arduino Digital 4
    LCD_D5   - Arduino Digital 5
    LCD_D6   - Arduino Digital 6
    LCD_D7   - Arduino Digital 7

    LCD_D0    - Arduino Digital 8
    LCD_D1    - Arduino Digital 9
    SD_SS       - Arduino Digital 10
    SD_DI        - Arduino Digital 11
    SD_DO      - Arduino Digital 12
    SD_SCK    - Arduino Digital 13


    LCD_RST   - Arduino Analog 5
    LCD_CS     - Arduino Analog 4
    LSD_RS      - Arduino Analog 3
    LCD_WR    - Arduino Analog 2
    LCD_RD     - Arduino Analog 1

    GND   - Arduino GND

    5V   - Arduino 5V
    3V3   - Arduino 3V

    LCD demo / statistics

    Another Arduino codebender program that worked on my shield is the program below.
    The first time you need to be patient before you see something on the display.
    The Serial Monitor outputs some statistic.





    This is a sample output on the Serial Monitor:

    TFT LCD test
    Using Adafruit 2.8" TFT Breakout Board Pinout
    TFT size is 240x400
    Found ILI9341 LCD driver
    240X400Benchmark                Time (microseconds)
    Screen fill              1652596
    Text                     403176
    Lines                    5247424
    Horiz/Vert Lines         171516
    Rectangles (outline)     103188
    Rectangles (filled)      3070180
    Circles (filled)         1658068
    Circles (outline)        2195988
    Triangles (outline)      1279256
    Triangles (filled)       1575676
    Rounded rects (outline)  594328
    Rounded rects (filled)   3623000
    Done!

    Some links






    Tuesday, August 23, 2016

    Arduino 1602A LCD with I2C

    Made LCD 1602A with I2C interface working with Arduino after using the Arduino LCD shield for some tests. The disadvantages of the Arduino LCD shield are that it uses s lot of the Arduino IO pins and fitting it in a nice box can give some problems with nthe IO connections.
    The module LCD1602A with an 16x2 display i received from China had a separate I2C interface module, so i soldered them first together.
    There are several discussions and misinterpretations about this module. I hope this post will help some people.
    It took me time than expected to get the module up and running. The problems where more hardware than software related. The article  http://forum.arduino.cc/index.php?topic=128635.0 on the Arduino forum helped me a lot.
    Here is how i finally got my LCD display working:

    Connect GND, VCC, SDA and SCL to the corresponding connections GND, VCC, SDA and SCL on the Arduino Uno. I did not connect them to the analog input lines as suggested.

    Use an I2C scan program to find the address of the LCD and write it down as you will need this in the next program. This I2C scan program worked for me and gave (on the console) the address

    Program to scan I2C

    Console / serial monitor

    Test the LCD with a program where, if needed, the I2C address is modified to the address found with the I2C scan program. This part was the most difficult. Sometimes adding libraries was needed, and even after this some additional libraries where also needed. Step one in the article on the Arduino forum also suggested downloading and renaming a library.
    Sometimes i observed reactions of the LCD (blinking/ flashing). Getting characters on the LCD screen did not work. I tested several programs.
    The real problem was the contrast of the pixels on the LCD. You can change the pixel contrast by inserting a screwdriver into the pot meter ( potentiometer ) at the back and turning it.
    For me the setting of the pot meter was the most critical step. Characters are visible only in a very small range.
    The pot meter is for the pixel contrast. The pot meter is NOT for the back-light !
    I already had played with this pot meter using some of the LCD programs but without success. The program where i had luck was written for a 4 x 20 display. I only had modified the I2C address in the program and suddenly during slow turning the pot meter i had my output.
    After this i modified the program for a 2 x 16 character output:

    Program to test LCD (2*16)


    Remark:

    It should be possible to change the I2C address using the A0 A1 A2 pins on the I2C interface. This way you can connect multiple displays.
    I did not test this (yet).