hallo Zusammen,
ich arbeite momentan mit VS C++ 2008 und wollte eine Verbindung mit den Arduino herstellen.
in VS habe ich 3 NumericUpdown, die als Winkeln X, Y und Z in arduino eingelesen sein sollten.
Hätte jemand vielleicht eine Lösung dafür ?

Im englischen Teil des Forum müssen die Beiträge und Diskussionen in englischer Sprache verfasst werden. Deswegen wurde diese Diskussion in den deutschen Teil des Forums verschoben.
mfg ein Moderator.
Tja...
Was gibts gegen die Serielle einzuwenden?
Oder Netzwerk?
Auch: CMDMessenger
genau, das habe ich genutzt, ich weiss nur nicht , wie ich die Eingaben einzeln getrennt einlese
Because it’s a custom application, you’ll need to define the protocol that is used to communicate with the Arduino (probably serial is the easiest), then you need to write a parser for that protocol on the Arduino.
Both these are mid-level programming projects.
Good learning opportunity.
how to import the entries separately
Depends on how you send them from VC
Protokoll erfinden.
Parser bauen.
Die SafeString-library bietet dazu eine Funktion an mit der man nicht-blockierend strings einlesen kann.
Die SafeString-library kann man über den library-Manager installieren.
Hier mal ein Demo-Code der parallel zum String-Einlesen die onboard-LED blinken lässt.
/*
SafeStringReader_flushInput.ino
This example flushes any initial input and also starts flushing if "flush" is found in the text stream
by Matthew Ford
Copyright(c)2021 Forward Computing and Control Pty. Ltd.
This example code is in the public domain.
download and install the SafeString library from Arduino library manager
or from www.forward.com.au/pfod/ArduinoProgramming/SafeString/index.html
*/
// SafeStringReader_flushInput.ino
// Reads words into a SafeString delimited by space or timeout
// uses line limit, timeout and input flushing
// https://www.forward.com.au/pfod/ArduinoProgramming/SoftwareSolutions/index.html
//
// download SafeString library from Arduino library manager
// or from the tutorial page
// https://www.forward.com.au/pfod/ArduinoProgramming/SafeString/index.html
//
// Pros: Minimal Code. Non-Blocking, Robust flushes any initial partial input, if flushInput() called in setup() or loop().
// Skips un-expected long input lines (missing terminator).
// Returns un-terminated input, if a timeout is set. Option echoOn() setting to echo all input.
// Cons: Nothing really, except needs SafeString library to be installed.
#include "SafeStringReader.h"
createSafeStringReader(sfReader, 20, " "); // a reader for upto 20 chars to read tokens terminated by space or timeout
void PrintFileNameDateTime() {
Serial.println( F("Code running comes from file ") );
Serial.println( F(__FILE__) );
Serial.print( F(" compiled ") );
Serial.print( F(__DATE__) );
Serial.print( F(" ") );
Serial.println( F(__TIME__) );
}
// easy to use helper-function for non-blocking timing
boolean TimePeriodIsOver (unsigned long &startOfPeriod, unsigned long TimePeriod) {
unsigned long currentMillis = millis();
if ( currentMillis - startOfPeriod >= TimePeriod ) {
// more time than TimePeriod has elapsed since last time if-condition was true
startOfPeriod = currentMillis; // a new period starts right here so set new starttime
return true;
}
else return false; // actual TimePeriod is NOT yet over
}
unsigned long MyTestTimer = 0; // Timer-variables MUST be of type unsigned long
const byte OnBoard_LED = 13;
void BlinkHeartBeatLED(int IO_Pin, int BlinkPeriod) {
static unsigned long MyBlinkTimer;
pinMode(IO_Pin, OUTPUT);
if ( TimePeriodIsOver(MyBlinkTimer,BlinkPeriod) ) {
digitalWrite(IO_Pin,!digitalRead(IO_Pin) );
}
}
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println(F("Setup-Start") );
PrintFileNameDateTime();
Serial.println(F("See the onboard-LED blink all the time") );
Serial.println(F("to demonstrate the non-blocking character") );
Serial.println(F("of the SafeString serial reader") );
Serial.println();
Serial.println(F("SafeStringReader_flushInput.ino"));
Serial.println(F(" Enter words separated by spaces, any initial buffered RX input (entered while counting down) is flushed"));
Serial.println(F(" Entering the word 'flush' clears the Serial TX buffer and skips to the next space or end of input timeout"));
SafeString::setOutput(Serial);
sfReader.setTimeout(1000); // set 1 sec timeout
sfReader.flushInput(); // empty Serial RX buffer and then skip until either find delimiter or timeout
sfReader.connect(Serial); // read from Serial
}
void loop() {
BlinkHeartBeatLED(OnBoard_LED,50);
if (sfReader.read()) { // got a line or timed out delimiter is NOT returned
if (sfReader.hasError()) { // input length exceeded
Serial.println(F(" sfReader hasError. Read '\\0' or input overflowed."));
}
if (sfReader.getDelimiter() == -1) { // no delimiter so timed out
Serial.println(F(" Input timed out without space"));
}
Serial.print(F(" got a line of input '"));
Serial.print(sfReader); Serial.println("'");
if (sfReader == "flush") {
sfReader.flushInput();
}
// no need to clear sfReader as read() does that
}
}
vgs
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.