Pages: [1]   Go Down
Author Topic: User interface query!  (Read 494 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Arduino community,

I'm thinking about creating a user interface to work with an Arduino however i'm having difficulty with how exactly I could code the software. Being a beginner, I understand coding simple programs, for example switching an LED on or off by inputing characters into the serial monitor. However, is it possible to code the serial monitor to act as a text-based, user friendly (console) application? What I mean is, could I code the serial monitor to ask the user the question: "Would you like to switch the LED on/off? Type yes or no." which the user would then enter "yes" or "no".  Another thing I want to do is to get the user to enter a position (e.g. x and y co-ordinates) and when this updated position is out outside a set range - switch the LED off, for example. I think I understand how I would code this without the arduino in a visual c++ or dev-cpp application but how would I code it with the Arduino software?! Unless there is a way to code an arduino using visual c++ but that seems complicated. Coding a normal application seems very different to coding an Arduino WITH an application...
Logged

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

if you know how to program it in general then you should know that you can add serial interface feature with many program langs. It is then the same as your sermonitor and arduino inerprets the commands the same
Logged

using Arduino Uno Rev 3

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok I don't fully understand your reply, what do you mean by serial interface features? I only want to code in C/C++ not other languages. The commands are not the same as you write things like "Serial.println" instead of "printf" if that's what you're saying. I want to code the serial monitor to ask some questions which the user will answer, rather than just put in "on" or "off" - I want a proper interface. I have yet to see anybody that has done that on the internet to show me that it can be done.
Logged

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Look something like C++ serial communication.

Your question, however, does not concern Arduino because you know everything how to read Serial messages and evaluate them...
It is just a question of C/C++ which I do not know very much of. I found some approach like
Code:
 HANDLE hFile =
 ::CreateFile("COM1",GENERIC_READ|GENERIC_WRITE,0,0,OPEN_EXISTING,0,0);
Maybe some C/C++ expert can explain you or better aks in a C/C++ forum (keyword: serial communication).

Here two links I found concerning your issue:
« Last Edit: October 26, 2012, 10:53:14 am by karlok » Logged

using Arduino Uno Rev 3

USA
Offline Offline
God Member
*****
Karma: 14
Posts: 644
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The links karlok provided address creating a separate user interface application with C/C++.  On the other hand, if you just want to use the Arduino IDE's serial monitor for two-way serial communication here's a simple tutorial to get you started.
Logged

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe I misunderstood you, alexrush.
Do you just want to use the Arduino Serial Monitor without external programs?
Then only the following commands are important
Serial.available()
Serial.read()
Serial.print(xyz)
Logged

using Arduino Uno Rev 3

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your input guys -  far-seeker, are you saying that I can only have a proper question-based user interface if I create a separate application using another IDE? Yes karlok - ideally I want to use the Arduino IDE for the interface - but all I have seen of it so far is you put in a command and it gets sent to the arduino. I want the user to be asked questions before you type a command! (eg What position are you? or Would you like to switch the LED off?) So I can just do that with Serial.print and if statements?
Logged

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I can just do that with Serial.print and if statements?
Exactly.

Furthermore, there are prebuilt functions like parseInt() and so on that automatically parse byte read inputs into an int or so.
(to know that: Serial.read() gives you a single byte of the buffer, so use something like while Serial.available()>0 do ....)
Logged

using Arduino Uno Rev 3

USA
Offline Offline
God Member
*****
Karma: 14
Posts: 644
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your input guys -  far-seeker, are you saying that I can only have a proper question-based user interface if I create a separate application using another IDE?

No, I was just making the distinction that what karlok originally suggested was along those lines. 

If you want to use the Arduino IDE's built-in serial monitor than the link I provided and karlok's latest reply should help you do that.
Logged

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Awsome - cheers guys!
Logged

Pages: [1]   Go Up
Jump to: