Arduino Dashboard

Dear All,
I have created an Arduino Dashboard that communicates with the arduino via the serial port. It takes design command from the arduino to display controls in the main window like button, combobox, checkbox, slider and graph. It also allows the plotting of values of a single source or all analog ports (6 for now). The source is written in Visual Basic and I am working on a Linux Port. Here some pictures, the source, the exe and a demo sketch can be found on my arduino pagehttp://www.mathias-wilhelm.de/arduino:

I hope you find it useful - enjoy

Ciao, Mathias

I downloaded your file (ArduinoDashboard v1.1.0), can't find any arduino demo sketch.

Salut,

the demo sketch is on the project page (as it is rather short) or here:

#include <MsTimer2.h>

int bufferCount;    // Anzahl der eingelesenen Zeichen
char buffer[80];    // Serial Input-Buffer
char temp[80];
char lastpin=2;
int blinkdelay;
boolean dbOpen = false;
boolean readPort = false;
boolean sglPort = false;
int maxSequence = 1;
int sequence = 0;
int c2chrt = 0;

void setup()
{
  Serial.begin(115200);
  for (int i=2;i<14;i++) {
    pinMode(i,OUTPUT);
  }
  MsTimer2::set(150, t2Isr); // 500 ms period
  MsTimer2::start();
}

void loop()
{
  // do nothing for the GUI handling, serial is done through interrupt
}

void serialEvent(){
  char ch = Serial.read();
  buffer[bufferCount] = ch;
  bufferCount++;
  if(ch == 13){
    evalSerialData();
  }
}

void evalSerialData()
{
  int ptr;
  int val;
  strcpy(temp,"");
  if ((buffer[0]=='S')&&(buffer[bufferCount-2]=='E')) {
    strncat(temp, buffer, bufferCount-1);
    if (strcmp(temp,"SQVERSIONE")==0){
      strcpy(temp,"AC 1.0.0");
    }
    if (strcmp(temp,"SINITE")==0){
      // setup the Dashboard
      Serial.println("STTL1Dashboard DemoE");
      Serial.println("SBTN001.0020.0040.0080.0025.Click MeE");
      Serial.println("SCKB001.0105.0040.Led 5E");
      Serial.println("SSLD001.0020.0070.0002.0013.0001.Led SwiperE");
      Serial.println("SSLD011.0020.0150.0000.0250.0025.Led FaderE");
      Serial.println("SCBO001.0020.0240.0080.0025E");
      Serial.println("SCBA001.Port A0E");
      Serial.println("SCBA001.Port A1E");
      Serial.println("SCBA001.Port A2E");
      Serial.println("SCBA001.Port A3E");
      Serial.println("SCBA001.Port A4E");
      Serial.println("SCBA001.Port A5E");
      Serial.println("SCBS001.0002E");
      c2chrt = 2;
      Serial.println("SLBL001.0250.0240.0080.0030.0.00E");
      Serial.println("SCKB011.0335.0040.Chart Timeline DataE");
      Serial.println("SCKB021.0105.0240.Show Port DataE");
      dbOpen = true;
    }
    if (strcmp(temp,"SGoodByeE")==0){
      // stop the Dashboard
      dbOpen = false;
    }
    if ((buffer[1]=='C')&&(buffer[2]=='K')&&(buffer[3]=='B')){
      ptr = (buffer[4]-48)*10 + (buffer[5]-48);
      if (ptr==0) {
        digitalWrite(5,((buffer[6]-48)==1));
      }
      if (ptr==1) {
        readPort = (buffer[6]-48)==1;
      }
      if (ptr==2) {
        sglPort = (buffer[6]-48)==1;
      }
    }
    if ((buffer[1]=='C')&&(buffer[2]=='B')&&(buffer[3]=='O')){
      ptr = (buffer[4]-48)*10 + (buffer[5]-48);
      c2chrt = buffer[12]-48;
      if ((c2chrt<0) || (c2chrt>5)) c2chrt = 0;
    }
    if ((buffer[1]=='B')&&(buffer[2]=='T')&&(buffer[3]=='N')){
      ptr = (buffer[4]-48)*10 + (buffer[5]-48);
      for (int i=2;i<14;i++) {
        digitalWrite(i,!(digitalRead(i)));
      }
    }
    if ((buffer[1]=='S')&&(buffer[2]=='L')&&(buffer[3]=='V')){
      ptr = (buffer[4]-48)*10 + (buffer[5]-48);
      val = (buffer[6]-48)*1000 + (buffer[7]-48)*100 + (buffer[8]-48)*10 + (buffer[9]-48);
      if (ptr==0) {
        digitalWrite(lastpin,LOW);
        lastpin=val;
        digitalWrite(lastpin,HIGH);
      }
      if (ptr==1) {
        analogWrite(10,val);
      }
    }
  } 
  else {
    strcpy(temp,"BadCmd: ");
    strncat(temp, buffer, bufferCount);
    Serial.println(temp);
  }
  bufferCount=0;
}

void t2Isr()
{  
  int led_pin = 13;
  int led_pin2 = 12;
  int ar[6];
  int val;
  char dstr[40];

  switch (sequence) {
  case 0:
    for (int i=0; i<6; i++) {
      ar[i] = analogRead(i) + i * 65;
    }
    sprintf(dstr,"STLViii.%4d.%4d.%4d.%4d.%4d.%4dE",ar[0],ar[1],ar[2],ar[3],ar[4],ar[5]);
    if (readPort) {
      if (dbOpen) {
        Serial.println(dstr);
      }
    }
    break;
  case 1:
    if (sglPort) {
      digitalWrite(led_pin, !digitalRead(led_pin));
      if (dbOpen) {
        val = analogRead(c2chrt);
        Serial.print("SLBV001.");
        Serial.print(millis() % 1000);
        Serial.println("E");
        Serial.print("SCHV001.");
        Serial.print(val);
        Serial.println("E");
      }
    }
  }
  sequence++;
  if (sequence>maxSequence) sequence = 0;
}

The project page also documents (work in progress) the syntax.

Ciao, Mathias

GastonLagaffe:
the demo sketch is on the project page (as it is rather short)

I agree that including the demo sketch in the download would be easier.

Havng copy-pasted the demo from your website, I got an error:

dashboard_demo:19: error: 'MsTimer2' has not been declared

I see

#include <MsTimer2.h>

so I guess this library from the playground needs to be installed. It would be useful to document any libraries that need to be installed.

The dashboard looks interesting, in particular the charting function (although that part seems to be undocumented as yet).

OK, it works. Scan ports is nice.

Pity that it shows an UNO board when I am using a Mega2560 :slight_smile:

More seriously, in the example sketch. the port dropdown shows A0 to A5, three times. Itrs not clear why; also, while ports with something connected are read corectly, ports with nothing connected display a sine wave. It would be nice to see what the random noise on an unconnected port looks like.

Salut,

ok - the picture is a challenge ... will introduce a version query that includes the board and amend the picture 8)

I will check the port read - bad news: From the reference of the analogRead() function:

Note

If the analog input pin is not connected to anything, the value returned by analogRead() will fluctuate based on a number of factors (e.g. the values of the other analog inputs, how close your hand is to the board, etc.).

If you get near an unconnected analog pin with your finger you will see your quality as an antenna :wink:

With respect to the triple set of dropdowns I have to change the code to accept a reset of the dropdown entries.

Ciao, Mathias

@Mathias very nice demo.