Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Read int from Arduino
Forum Update on Monday, May 27th 2025

Read int from Arduino

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gtpt
    wrote on 7 Nov 2013, 17:10 last edited by
    #1

    Hi:

    I want to read and write an int from Arduino.
    I'm using "QSerialPort":http://qt-project.org/doc/qt-5.1/qtserialport/qserialport.html and so far Qt only receives "garbage" form Arduino.

    The code from Arduino is:
    @
    int myDelay = 1000;

    void setup()
    {
    Serial.begin(9600);
    }

    void loop()
    { while (Serial.available() <= 0)
    {
    Serial.print(myDelay);
    }
    myDelay = Serial.read();
    Serial.flush();
    }
    @

    This read and sends data from Qt.
    Sender from Qt:
    @void Dialog::enviarAtraso(int valor)
    {
    serial->write(QString::number(ui->atraso->value()).toLocal8Bit());
    // ????
    }@

    Reader from Qt:
    @void Dialog::readResponse()
    {
    response->append(serial->readAll());
    int x = 33; //sample value
    // response to int here
    // ...
    // ...
    ui->recebido->setText(QString::number(x));
    response->clear();
    }@

    response is a QByteArray.

    Any sugestion in order to establish this communication?
    Thanks

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on 7 Nov 2013, 17:43 last edited by
      #2

      bq. Any sugestion in order to establish this communication?

      Read documentation, look examples.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gtpt
        wrote on 7 Nov 2013, 20:42 last edited by
        #3

        Perhaps i did not make my self clear!
        My question is about datatypes and converting them into/from QByteArray.
        The communication is working fine ...

        1 Reply Last reply
        0

        1/3

        7 Nov 2013, 17:10

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved