Go Down

Topic: String numeric output with V-USB HID (Read 16533 times) previous topic - next topic

mrburnette

Quote
How is it possible to use the millis() function, because of timer0 is disabled?


We write our own:

Code: [Select]

void delayMs(unsigned int ms) {    // Safe delay helper function
  for (int i = 0; i < ms; i++) {
    delayMicroseconds(1000);
  }
}


Ray

PS: I have not gotten this rolled into the forum yet, but it is way cool.... HID bidirectional and it does not enumerate as a HID keyboard... the downside is that you do have to install the avrisp INF under Windows.
http://www.hackster.io/rayburne/analog-digital-port-viewer-usb

jmnijsse

Oke, this is an delay-function.
But I want to write the time in excel since beginning of the program.
So we can draw such as a time-temperature chart.

Or I don't understand it well?

Thanks for hint, but the installation of a driver is just what we don't want.

J.


mrburnette

Quote
But I want to write the time in excel since beginning of the program.


Take a look at how to send a string over USB:
Code: [Select]

sOut = "UNO 328P EXAMPLE - RAY BURNETTE C20121210";
KeyStrokeAlpNum(sOut);


If you have implemented RTC hardware, it is simply a matter of updating the variables from the RTC, concatenating date/time into a string, and using KeyStrokeAlpNum(sTimeDate) to send it over USB into Excel.

The Excel worksheet will require editing because you will be adding additional information.

You can also write an Excel macro (or VBA) with a keyboard shortcut so that the Excel document will time-date stamp, then you simply send the keyboard codes for that macro over the V-USB connection and Excel will oblige.  Looking at the existing output, there is currently a blank line being sent so you could put your time/date stamp in the blank cell (Ex: A5, A13, A21, etc.)

If you want to just send the millisecond count from the time the Arduino was last Reset/PoweredOn, then the magic for doing that is similar to:
Code: [Select]

    for (int i = 0; i < 6; i++){
      // read the analog in value:
      sensorValue = analogRead( i );
      // Label the value
      sOut = "ANALOG";
      // String the characters together
      sOut.concat(String(i));
      sOut.concat(" ");
      sOut.concat(String(sensorValue));
      // spool the combined strings
      KeyStrokeAlpNum(sOut);
    }


Ray


Go Up