⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serialduplex.pde

📁 This is processing for java examples.
💻 PDE
字号:
/** * Serial Duplex  * by Tom Igoe.  *  * Sends a byte out the serial port when you type a key * listens for bytes received, and displays their value.  * This is just a quick application for testing serial data * in both directions.  */import processing.serial.*;Serial myPort;      // The serial portint whichKey = -1;  // Variable to hold keystoke valuesint inByte = -1;    // Incoming serial datavoid setup() {  size(400, 300);  // create a font with the third font available to the system:  PFont myFont = createFont(PFont.list()[2], 14);  textFont(myFont);  // List all the available serial ports:  println(Serial.list());  // I know that the first port in the serial list on my mac  // is always my  FTDI adaptor, so I open Serial.list()[0].  // In Windows, this usually opens COM1.  // Open whatever port is the one you're using.  String portName = Serial.list()[0];  myPort = new Serial(this, portName, 9600);}void draw() {  background(0);  text("Last Received: " + inByte, 10, 130);  text("Last Sent: " + whichKey, 10, 100);}void serialEvent(Serial myPort) {  inByte = myPort.read();}void keyPressed() {  // Send the keystroke out:  myPort.write(key);  whichKey = key;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -