Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
techniken:datenaustausch:processingserialread [2016/08/03 17:22] fbonowski [Beispielcode:] |
techniken:datenaustausch:processingserialread [2016/11/16 13:49] (aktuell) fbonowski |
||
---|---|---|---|
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 |