2

What's the best/easiest software to make a PC-Arduino interface? Ideally, I need to create a .exe that shows up a simple graphic interface, where the user can display data acquired from sensors connected to the Arduino (eg. Voltage, current etc.) and from there he should be able to control Arduino outputs through graphical buttons/switches.

To say that I am not a programmer, so if there's some sort of 'graphical coding' or 'non coding' software to make such things it'd be great!

Thanks for your help!!!

UPDATE:

Image of how the user interface should look like:

Image of how the user interface should look like

Andy
  • 103
  • 2
  • 2
  • 7

3 Answers3

3

The "best" software for me is the free Visual Studio Express for Desktops.

Using C#, I would add a SerialPort component to the form, configure it for the same COM port as the Arduino/FTDI, then send commands to it.

VS Visual Studio is "stupid simple" (I'm not implying anything :D). Double-click Button in the toolbox(1) and it creates one. Double click the button(2), and it outlines the code and attaches the Click event to it for you. Double click Components>SerialPort(3) to create one. My code is highlighted in blue to the right and this took all of 1 minute to create.

To point you in the right direction on the Arduino side, here is the structure of the "command" I sent in the screenshot:

XXXYYYZZ
Where:
XXX = 000b for "turn off", 001b for "turn on", 010b for "toggle", 011b for "read pin"
YYY = Pin number //Max = 111b = 7 (+ 0) = 8 uniquely addressable pins (using 3 bits)
//Pin number does not have to match the MCU port/pin designations
//MCU will convert logical pin #'s 0-7 into the correct physical port+pin
//For more pins, steal another bit from ZZ; Max for YYYY = 1111b = 15
ZZ = Spare bits //Tell the Arduino whether to acknowledge or not, etc.

00100100b = "Set pin 1 high"
01001000b = "Toggle pin 2"
10000000b + 0xAA (two byte command) = "Reply with contents of register 0xAA"

Additional commands can be created to tell the Arduino to reply with a specific variable or status.

bool isRegisterRead = false;
bool isMultiByte = false;
while (true)
 if (wasByteReceived) //This flag is set in the RX interrupt and the byte is saved to byteReceived
  if (isMultiByte) //Second byte received
  {
    if (isRegisterRead)
    {
      //We need to read and send the value of the register at the address in byteReceived
      ReadAndSendRegisterValueAtAddress(byteReceived);
      isRegisterRead = false;
    }
    else DoSomethingWith(byteReceived);
    isMultiByte = false; //Start over
  }
  else //First or only byte received
  {
    //Consider using a ZZ bit to indicate more data instead of listing them explicitly
    if (byteReceived == 0x80) //A multi-byte "read register" command
    {
      isMultiByte = true; //Next byte received is money
      //For my example we need to set a flag somewhere to indicate that we are reading a register
      //isRegisterRead should be set to true by DoSomethingWith
    }
    //Is there any processing for the "command" byte? (i.e. extract and save the pin number)
    DoSomethingWith(byteReceived); //Process one-byte command or first of two-byte command
  }
per1234
  • 4,278
  • 2
  • 24
  • 43
Jon
  • 466
  • 2
  • 5
2

Almost impossible to answer really. Questions with "best" are always going to yield opinions which probably won't apply to your situation. For example, I would do a C# desktop application because that's what I do, and nothing in that environment hinders communication with an Arduino. So, what's best for me is best because of "familiar and will work" and we can't decide what meets those criteria for you.

If you will update your question to describe more about your application, details about your interface, users, and what skills you have, then I will update this answer, but as it stands "the world is your oyster" because almost any programming environment capable of making an application will be able to interface with Arduino in some way.

For "graphical" programming look into LabView - I can think of a lot of reasons to not go that way though. http://www.ni.com/labview/

Here's a tutorial for interfacing a c# application with Arduino: http://www.codeproject.com/Articles/473828/Arduino-Csharp-and-Serial-Interface

The gist of it is this:

  1. Some version of Visual Studio up and running - you can use the free version mentioned in Jon's answer (Express version for desktops).
  2. A working Arduino connected to your computer with the USB.
  3. Create a new Windows Forms Application and drop whatever controls you need onto the form
  4. Write your Arduino-connecting code into the events of the controls

That is the basic method of creating Windows Forms apps regardless of what you're doing. You create forms with controls and your custom code goes into the events of those controls. If you read the tutorial it explains how that code works, but here's a sample... (In the tutorial, they are doing a WPF app, which is slightly different from Windows Forms in how the controls are defined, but the code is basically the same). This is an event of the serial port - you respond to the event by displaying the received data into a text box. Very simple!

void mySerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) {
    string data = mySerialPort.ReadTo("\x03");
    myForm.myTextBox.Text = data;
}
Jasmine
  • 461
  • 2
  • 6
1

3 votes for visual studio and a windows desktop, although I would chose WPF. Win32 (Winforms) is a slightly out of date architecture. WPF has a steeper learning curve, but worth it if you want to become proficient. If it is a one off application, don't bother, use winforms.

I'll add a couple of points. Debugging Arduino sucks. I am being kind. The Arduino IDE deploys on com port 1, and prints debugging messages on com port 1, so if you need to communicate un-interrupted by debugging and deployment, what do you use? Not com port 1 for sure. Look at software serial in the beginning and assign ports around its requirements.

Second, writing your own com stack is dumb, yet is done 99% of the time. Look at MQTT if ethernet is available, MQTT-SN if it is not, CmdMessenger or CommandSerial or something similar or spend days designing, writing, re-writing and debugging your own, your choice.