Control your arduino from your PC with the Qt Gui
Explore
(/) (/)
http://www.instructables.com/id/Control-your-arduino-from-your-PC-wit...
Create (/about/submit.jsp) Contests (/contest/) Community (/community/)
You (/you/)
(/tag/type-id/)
Control your arduino from your PC with the Qt Gui by intructable (/member/intructable/)
Download (/id/Control-your-arduino-from-your-PC-with-the-Qt-Gui/?download=pdf) (/id/Control-your-arduino-from-your-PC-with-the-Qt-Gui/) 5 Steps
+ Collection
Favorited
drag the slider to change the brightness
(/files/deriv/FFC/JRAH/GP2DLDTP/FFCJRAHGP2DLDTP.LARGE.jpg)
About This Instructable
36,360 views 22 favorites
Posted: Jun 18, 2011 License:
intructable (/member /intructable/)
Follow 6
(/member /intructable/) More by intructable
(/files/deriv/FHA/NG0Q/GP2DLDU3/FHANG0QGP2DLDU3.LARGE.jpg)
For my first instructable I will show you how to use Qt to make graphic interfaces for your arduino (or any rs232 device) So if you want to create your own graphic interfaces, you want to control stuff just by clicking buttons from your screen, this instructable is for you. To do this we will use Qt (say : "cute") from nokia. Of course Qt is not the only program that can make graphical interface. But these are the advantages of Qt : - It is free and open source software (distributed under the terms of the GNU Lesser General Public License) - It is C/C++, so widely used.
(/id/Make-graphs-on-Qtand-plot-your-arduino-measuremen)
(/id/arduino-module-for-timelapse-photography)
Tags:
Arduino (/tag/type-id/category-technology/keywordarduino/)
1 de 10
02/10/2013 05:20 p.m.
Control your arduino from your PC with the Qt Gui
http://www.instructables.com/id/Control-your-arduino-from-your-PC-wit...
Qt (/tag/type-id/category-technology/keyword-qt/) Programming (/tag/type-id/category-technology /keyword-programming/) RS232 (/tag/type-id/category-technology/keywordrs232/) basic (/tag/type-id/category-technology/keywordbasic/) Gui (/tag/type-id/category-technology/keyword-gui/) Graphic (/tag/type-id/category-technology/keywordgraphic/) Interface (/tag/type-id/category-technology/keywordinterface/)
- You can compile your program on a lot of platform (Windows, Linux, ...) - The possibilities are infinite (you probably have many applications coded on Qt : Skype, Google Earth, VLC, ... I only provide basic things to start. Here we just see how to install Qt, the serial port library and write your first program. The program will control the brightness of a led. I admit that you already know know C/C++. If it is not the case, there are plenty of course on the web. If your are a french speaker (like me), I suggest the course from www.siteduzero.fr (http://www.siteduzero.com) which is very good to start from zero.
Add instructable to:
Group
Related
Make graphs on Qt and plot your arduino measurements (/id/Make-graphs-on-Qtand-plot-your-arduinomeasuremen/) (/id/MakeCheap lcd screen for the Arduino. (/id/Cheaplcd-screen-for-the-Arduino/) by Computothought (/member
/Computothought/)
(/id/Cheap-
AVR ISP programmer (/id/AVR-ISP-programmer/) by Milen (/member/Milen/)
Step 1: Intallation of Qt
(/id/AVRDMM Piggyback (add RS-232) (/id/DMM-Piggybackadd-RS-232/) by jazzzzzz (/member/jazzzzzz/) Pocket Ardiuno kit. (/id/Pocket-Ardiuno-kit/) by Bongmaster (/member
/Bongmaster/)
(/id/DMM-
(/files/deriv/FKF/LCS7/GP2DMGCT/FKFLCS7GP2DMGCT.LARGE.jpg)
(/id/PocketSee More (/tag/type-id/?q=)
The first step of this instructable is to get and install Qt. You can get Qt sdk from this wedsite : http://qt.nokia.com/products/ (http://qt.nokia.com/products/) Once downloaded, follow the instruction to install it. The first part is over. Fairly easy, isn't it? The next part is a bit more tricky.
Step 2: Installation of the library
2 de 10
02/10/2013 05:20 p.m.
Control your arduino from your PC with the Qt Gui
http://www.instructables.com/id/Control-your-arduino-from-your-PC-wit...
(/files/deriv/FJB/EXT6/GP2DMGIW/FJBEXT6GP2DMGIW.LARGE.jpg)
(/files/deriv/F3Z/38UP/GOW3YXOZ/F3Z38UPGOW3YXOZ.LARGE.jpg)
Even if Qt is very huge and provides a lot of tools, there is one thing which is missing in our case : the serial port functions. So we have to install a library to be able to communicate with the port com. To do this I use the qextserialport library (version 1.2alpha). First you need to download the library on sourceforge : http://sourceforge.net/projects/qextserialport/files/ (http://sourceforge.net/projects/qextserialport/files/) or the last version here http://code.google.com/p/qextserialport/ (http://code.google.com/p/qextserialport/) Then you extract the files. Here comes the tricky part. The files you downloaded are not compiled. So you must compiled them. To do so you must start the Qt prompt console. You can find it on Windows in :
3 de 10
02/10/2013 05:20 p.m.
Control your arduino from your PC with the Qt Gui
start menu, Qt SDK, Desktop, Qt 4.7.3 for Desktop (MinGW) Then send the command that are on picture 2.
http://www.instructables.com/id/Control-your-arduino-from-your-PC-wit...
Make sure that a new folder "build" was created during the compilation and the files qextserialportd.dll and libqextserialportd.a are present. Congratulation, you perfectly compiled the library!
Step 3: Let's program
(/files/deriv/FGK/XCUE/GP2DLE36/FGKXCUEGP2DLE36.LARGE.jpg)
(/files/deriv/FGS/LSN6/GP2DLE5E/FGSLSN6GP2DLE5E.LARGE.jpg)
Now everything is installed, we can start to program. Open Qt Creator and create a new project. I join an example of the program, there are a lot of comments which will help to understand. The main things to know are : - you have to include the library in your .pro file (see the example) - to connect a port, you need to create a variable, to open the port and then to configure it (in this order). (Don't forget to put the right number of your port) - to send a message through, use the function write(char*). - to receive data use the function read : int numBytes =portcom.bytesAvailable(); char buff[256]; portcom.read(buff, numBytes);
4 de 10
02/10/2013 05:20 p.m.
Control your arduino from your PC with the Qt Gui
http://www.instructables.com/id/Control-your-arduino-from-your-PC-wit...
(you can also use the signal readyRead() to launch function when a data arrives) - if when compiling you have the error n1073741515 (or maybe another) that mean that you need to put the qextserialportd.dll into your .exe folder.
You can find other examples in the library example folder. That will teach you how to scan the ports or receive data.
portcomsender.rar
(/files/orig/F3O/TV95/GP2DMHVW/F3OTV95GP2DMHVW.rar)3 KB
Step 4: Program your Arduino
(http://cdn.instructables.com/F5I/JXWE/GOW3YXUG/F5IJXWEGOW3YXUG.LARGE.jpg)
The last part is very easy. Plug a led with its resistance to the 9 pin. Then you just have to load the program present in Examples => Communication => Drimmer. Here is the relevant part of the program : const int ledPin = 9; // the pin that the LED is attached to void setup() { // initialize the serial communication: Serial.begin(9600); // initialize the ledPin as an output: pinMode(ledPin, OUTPUT); } void loop() { byte brightness;
5 de 10
02/10/2013 05:20 p.m.
Control your arduino from your PC with the Qt Gui
// check if data has been sent from the computer: if (Serial.available()) { // read the most recent byte (which will be from 0 to 255): brightness = Serial.read(); // set the brightness of the LED: analogWrite(ledPin, brightness); } } Start your Qt program and control the pin 9 voltage.
http://www.instructables.com/id/Control-your-arduino-from-your-PC-wit...
Step 5: Conclusion
(http://cdn.instructables.com/FTQ/8MIM/GOW48T7V/FTQ8MIMGOW48T7V.LARGE.jpg)
In this instructable, we have see how to use Qt to control your arduino. I know that this example is very minimalist, but I'm sure that you will be able to start bigger project. Next time I will show you how to plot graph on Qt, so you could also monitor temperature, pressure... PS : As you probably notice it, I am not a native English speaker, I would be please if you can correct me.
We have a be nice comment policy. Please be positive and constructive.
Rich Editor
Add Images
Preview
Post
6 de 10
02/10/2013 05:20 p.m.
Control your arduino from your PC with the Qt Gui
jloibman (/member/jloibman/) says: Jul 8, 2013. 7:27 AM
http://www.instructables.com/id/Control-your-arduino-from-your-PC-wit...
Reply (CZQYK34HIUWWYH0)
OK, I just sad that I can't use your tutorial, it's so well explained.. I saw at code.google.com/p/qextserialport that there is support for Qt5 so I thought I could follow your (/member tutorial.. /jloibman/) Do you still use Qt 4.7.3? Is there any chance you got the qt SDK installer?
flag
jloibman (/member/jloibman/) says:
Jul 7, 2013. 8:36 PM
Reply (CIOU2JMHIUWWXZZ)
(/member manage to have on my PC is Qt 5.1.0 with Mingw. If you can get in touch with me by email I'll be so /jloibman/)
Hello. I tried to follow the steps but it didn't work on qt5.1. Do you know how do I do that? I even tried to download and install qt 4.7.3, but with no success.. Hope you can help me. So what I could grateful too.. My email is [email protected]
flag
intructable (/member/intructable/) (author) in reply to jloibman Reply (CH9PDMHHIUXBHA4) Jul 7, 2013. 11:44 PM The library does not seem to work on qt5.X. Instead you might use this 3 new Qt add-on : http://qt-project.org (/member /wiki/QtSerialPort , I have not tried /intructable/) but I think it has the same features that the qtserialport library.
flag
tsun1 (/member/tsun1/) says: Hi,
Aug 18, 2012. 11:20 PM
Reply (C0Z9GU0H5Y9VMIJ)
(/member I've been working on your examples theses days. Unfortunately, every time last build step, Qt showed /tsun1/)
up: enumwidget.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall QextSerialPort::QextSerialPort(class QString const &,enum QextSerialBase::QueryMode)" ( ??0QextSerialPort@@QAE@ABVQString@@W4QueryMode@QextSerialBase@@@Z) referenced in function "public: void __thiscall Widget::init_port(void)" (?init_port@Widget@@QAEXXZ). Any suggestions?
flag
varuninnz (/member/varuninnz/) says: Hey mate,
Aug 11, 2012. 10:32 PM
Reply (C7L69HTH5JVY3IZ)
(/member I went to my Qt SDK desktop. I had 4.7.4 & 4.8.1. /varuninnz/)
I followed both your instruction for both 4.7.4 & 4.8.1 just like you've showed them in the picture. And it seemed to work exactly how its displayed on your cmd window. Also instead I downloaded the beta file. QextSerialPort_1_2_Beta2. But I believe the procedure is very similar. Then the next, I did was open the project file from your portcomsender. After this I went inside the portcomsender.pro and changed the INCLUDEPATH += C:/Qt/qextserialport-1.2win-alpha/ LIBS += C:\Qt\qextserialport-1.2win-alpha\build\libqextserialportd.a to INCLUDEPATH += C:/qt/qextserialport-1.2beta/ LIBS += C:\Qt\qextserialport-1.2beta\buildlib\buildlib.pro I did this because I could not libqextserialportd.a or any .dll files. Im really not sure what to do here. Should I just copy the ibqextserialportd.a & .dll files from the aplha to the buildlib of the beta folder?
7 de 10
02/10/2013 05:20 p.m.
Control your arduino from your PC with the Qt Gui
http://www.instructables.com/id/Control-your-arduino-from-your-PC-wit...
flag
intructable (/member/intructable/) (author) in reply to varuninnz Reply (CPXI2EEH5JVOVMV) Aug 12, 2012. 7:33 AM Hi varuninnz I am not sure that you should export 3 the alpha files to the beta folder, this (/member might be a bad idea. /intructable/) I have not tried the beta yet so I don't know what you have to do. You should probably check what the developers expect you to do to run this new library. Usually you can easily find instructions in the downloaded files. Tell me when you find a solution to your problem. Cheers
flag
jkrishna1 (/member/jkrishna1/) says:
Jun 29, 2012. 2:13 AM
Reply (C38QVL3H3Z3207T)
When i typed in this "F:\QtSDK\qextserialport-1.2win-alpha>f:\QtSDK\mingw\bin\mingw32-make.exe "
(/member following error comes, /jkrishna1/)
sbs -c winscw_udeb.mwccinc sbs: error: tool 'MWLD' from config 'none' did not return version 'Version 3.2.* ' as required. Command 'mwldsym2.exe -version' returned: /bin/bash: mwldsym2.exe: command not found Check your environment and configuration. What went wrong?
flag
1o_o7 (/member/1o_o7/) says:
Mar 28, 2012. 3:57 PM
Reply (CZ4ZK8XH0CQ5QFR)
2 (/member /1o_o7/)
Here is the latest qextserialport project. It is no longer at sourceforge. http://code.google.com/p/qextserialport/
flag
3 (/member /intructable/)
intructable (/member/intructable/) (author) in reply to 1o_o7 Mar 29, 2012. 12:03 AM Thanks, I change the link.
Reply (CVMEVP4H0AR6SPV)
flag
mojocorp (/member/mojocorp/) says: Hi, There is a mistake in the code: char *buf; //creation of a buffer *buf = value;
Nov 17, 2011. 1:21 PM
Reply (CIXSW4QGV2UVFRS)
(/member /mojocorp/)
buf point to random memory and changing the value may randomly crash. char buf = (char)value; port->write(&buf, 1); //send the buffer or better port->write(QByteArray(1, (char)value)); //send the buffer
flag
8 de 10
02/10/2013 05:20 p.m.
Control your arduino from your PC with the Qt Gui
http://www.instructables.com/id/Control-your-arduino-from-your-PC-wit...
intructable (/member/intructable/) (author) in reply to mojocorp Reply (CTELDKBGV0KY0MJ) Nov 18, 2011. 12:46 AM It is correct, Another solution is to 3 allocate the pointer with a (/member "new" : /intructable/) char *buf; buf = new char; and then delete the pointer to avoid a memory overflow : delete buf; This is a mistake I often do because these problems are sometime solved during the compilation. Thank you for your comment and fill free to correct me again.
flag
Helm21 (/member/Helm21/) says: Some helpful hints...
Oct 27, 2011. 12:50 PM
Reply (CYD4M36GUA4738Y)
(/member 1. In the QtCreator I had to change the 'build configuration' under "Projects" (on the left side) from /Helm21/)
Debug to Release
2. The two lines char *buf; *buf = value; caused a crash of my programm. The compiler did its job, but when I ran the prog und called the method "transmitCmd(int value)", it crashed. I thing the conversion from int to char isn't possible this way... I did it this way: char buf; buf=(int)value; port->write(&buf); 3. All included DLL-files have to be copied in the C:/WIndows folder
flag
About Us
Who We Are (/about/) Advertise (/advertise/) Contact (/about/contact.jsp) Jobs (/community?categoryGroup=marketplace&category=jobs_internships) Help (/community?categoryGroup=Help)
Find Us
Facebook (http://www.facebook.com/instructables) Youtube (http://www.youtube.com/user/instructablestv) Twitter (http://www.twitter.com/instructables) Pinterest (http://www.pinterest.com/instructables)
Resources
For Teachers (/teachers/) Artists in Residence (/group/air/) Forums (/community/) Answers (/tag/type-question/?sort=RECENT)
Mobile
Download our new apps for iOS and android!
Android (https://play.google.com
Copyright 2013 Autodesk Inc. All rights reserved /store (http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112) Join! Terms of service (/tos.html) | Privacy (http://usa.autodesk.com/privacy/) | Legal Notices & Trademarks (http://usa.autodesk.com/legal-notices-trademarks/) | Mobile Site /apps/details?id=com.adsk.instructables) (http://m.instructables.com)
iOS (https://itunes.apple.com /app/instructables /id586765571)
9 de 10
02/10/2013 05:20 p.m.
Control your arduino from your PC with the Qt Gui
Visit Our Store (http://store.instructables.com/)
http://www.instructables.com/id/Control-your-arduino-from-your-PC-wit...
Go Pro Today (/account/gopro?sourcea=footer)
10 de 10
02/10/2013 05:20 p.m.