Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
techniken:datenaustausch:processingserialread [2016/01/21 12:45] 127.0.0.1 Externe Bearbeitung |
techniken:datenaustausch:processingserialread [2016/11/16 13:49] (aktuell) fbonowski |
||
---|---|---|---|
Zeile 35: | Zeile 35: | ||
</code> | </code> | ||
- | ====== Beispielcode: ====== | + | ====== Beispielcode Empfang von Zahlenwerten: ====== |
<file Java receiveDataSerial.pde> | <file Java receiveDataSerial.pde> | ||
Zeile 50: | Zeile 50: | ||
// Initialze Serial communication. There may be multiple serial ports on your computer, so we have to select one: | // Initialze Serial communication. There may be multiple serial ports on your computer, so we have to select one: | ||
- | String[] portNames=Serial.list();//Serial.list() returns an array of port names | + | String[] portNames=Serial.list();//Serial.list() returns an array of port names |
+ | // if there is no serial port, quit with an error message | ||
+ | if (portNames.length==0){throw(new IllegalStateException("There are no Serial ports on this computer!"));} | ||
println(portNames); //print them to the user | println(portNames); //print them to the user | ||
// initialize the Serial port Object using the last name from the list and a Baudrate of 9600 | // initialize the Serial port Object using the last name from the list and a Baudrate of 9600 |