Friday, July 5, 2013

Qt Terminal example work with Arduino

The new released Qt 5.1 come with a number of examples, Terminal is one of them. The Terminal example shows how to create a terminal for a simple serial interface by using Qt Serial Port. It shows the main features of the QSerialPort class, like configuration, I/O implementation and so forth. Also, the class QSerialPortInfo is invoked to display information about the serial ports available in the system.

We can load and run it to communication with Arduino Due board easily.

To load the terminal example:

- Click File on Qt menu, -> select Open File or Project..., browse to load the project file of Terminal example. It should be locate in /Qt/5.1.0/gcc/examples/serialport/Terminal/terminal.pro.

Build and run the example:


Code in Arduino Due:

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

void loop() {
  if(Serial.available() > 0){
    Serial.print('(');
    Serial.print((char)Serial.read());
    Serial.print(')');
  }
}



No comments:

Post a Comment