Go Down

Topic: User interface query! (Read 704 times) previous topic - next topic

alexrush

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...

karlok

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
using Arduino Uno Rev 3

alexrush

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.

karlok

#3
Oct 26, 2012, 05:43 pm Last Edit: Oct 26, 2012, 05:53 pm by karlok Reason: 1
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: [Select]
 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:
using Arduino Uno Rev 3

Far-seeker

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.

karlok

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)
using Arduino Uno Rev 3

alexrush

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?

karlok


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 ....)
using Arduino Uno Rev 3

Far-seeker


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.

alexrush


Go Up