Results 1 to 6 of 6

Thread: QT5 Use wiringpi i2c lcd example Pls

  1. #1
    Join Date
    Nov 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Post QT5 Use wiringpi i2c lcd example Pls

    Hi, in designer Button display Status LED But i want to display Lcd 16x2 + i2c
    command sudo i2cdetect -y 1
    address 0x27
    and include not error

    #include "wiringPiI2C.h"
    #include "wiringPi.h"

    wiringPisetup();
    wiringPiI2CSetup(27);
    LcdDisplay("Test",0);

    after run not Display to Lcd
    Help Me Pls

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QT5 Use wiringpi i2c lcd example Pls

    There is not nearly enough code to understand what you are doing.

    E.g. there is no indication what "LcdDisplay" is, whether this has anything to do with Qt at all, if you created and started the Qt applicaition object if it is, etc.

    Cheers,
    _

  3. #3
    Join Date
    Nov 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QT5 Use wiringpi i2c lcd example Pls

    Quote Originally Posted by anda_skoa View Post
    There is not nearly enough code to understand what you are doing.

    E.g. there is no indication what "LcdDisplay" is, whether this has anything to do with Qt at all, if you created and started the Qt applicaition object if it is, etc.

    Cheers,
    _
    i want display data to LCD 16x2

    Diagrama-RaspberruPi-LCD-I2C-550x485.jpg

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QT5 Use wiringpi i2c lcd example Pls

    Ok, so nothing to do with Qt.
    Moving to a better section.

    Cheers,
    _

  5. #5
    Join Date
    Nov 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QT5 Use wiringpi i2c lcd example Pls

    Quote Originally Posted by anda_skoa View Post
    Ok, so nothing to do with Qt.
    Moving to a better section.

    Cheers,
    _
    Final Code QT5
    Connect I2C(PCF8574) + LCD Char 16x2
    Show Text After Key in
    On Off Blacklight

    Qt Code:
    1. #include "mainwindow.h"
    2. #include <QApplication>
    3. #include <QWidget>
    4. #include <QtCore>
    5. #include <QtGui>
    6. #include <QMessageBox>
    7. #include "ui_mainwindow.h"
    8. #include <wiringPi.h>
    9. #include <pcf8574.h>
    10. #include <lcd.h>
    11.  
    12. #define LCDOFS(x)(lcdofs+x)
    13.  
    14. const int lcdofs=0x64;
    15. const int fd=lcdInit(2,16,4,LCDOFS(0),LCDOFS(2),LCDOFS(4),LCDOFS(5),LCDOFS(6),LCDOFS(7),0,0,0,0);
    16. MainWindow::MainWindow(QWidget *parent) :
    17. QMainWindow(parent),
    18. ui(new Ui::MainWindow)
    19. {
    20. pcf8574Setup(lcdofs,0x3f);
    21. wiringPiSetup();
    22. ui->setupUi(this);
    23. }
    24.  
    25. MainWindow::~MainWindow()
    26. {
    27. delete ui;
    28. }
    29.  
    30. void MainWindow::on_pushButton_clicked()
    31. {
    32.  
    33. QString str;
    34. str =ui->lineEdit->text();
    35. pinMode(LCDOFS(1),OUTPUT);
    36. pinMode(LCDOFS(3),OUTPUT);
    37. digitalWrite(LCDOFS(1),0);// 0=Character New Lcd ;1= Character Not New
    38. digitalWrite(LCDOFS(3),1);// 0=off;1=on Backlight off
    39. lcdHome(fd);
    40. lcdClear(fd);
    41. lcdPosition(fd,0,0);
    42. lcdPrintf(fd,ui->lineEdit->text().toUtf8());
    43. lcdPosition(fd,0,1);
    44. lcdPrintf(fd,ui->lineEdit_2->text().toUtf8());
    45.  
    46. // digitalWrite(LCDOFS(1),1);//
    47. QMessageBox msgbox;
    48. msgbox.setWindowTitle("Message Box");
    49. msgbox.setText(str);
    50.  
    51. msgbox.exec();
    52. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by akachai; 14th November 2016 at 06:53.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QT5 Use wiringpi i2c lcd example Pls

    And what do you get vs. what did you expect to get?
    Have you done any error checking?

    E.g. shouldn't you call wiringPiSetup() before calling any of the other functions from that library?
    Have you checked that lcdInit() works when called before that?

    Cheers,
    _

Similar Threads

  1. wiringpi serial communication
    By rapid84 in forum Qt Programming
    Replies: 1
    Last Post: 3rd January 2016, 07:29

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.