Firmata

Firmata:是一種通訊協定(protocol),是一種用於微控制器與電腦中軟體間的協助通訊的通訊協定。

https://github.com/firmata/arduino

Tools for testing
https://github.com/firmata/firmata_test/downloads

http://firmata.org/wiki/Main_Page

https://www.cnblogs.com/sjqlwy/p/lattepanda_firmata.html

Using Firmata to control Arduino by Processing

Arduino Program:
Standard Firmata example
Processing:(need to install the arduino first)
import processing.serial.*;
import cc.arduino.*;

Arduino arduino;
int ledPin = 13;

void setup()
{
  //println(Arduino.list());
  arduino = new Arduino(this, Arduino.list()[0], 57600); 
// the Arduinio.list()[0] can be replace as "COM12"
  arduino.pinMode(ledPin, Arduino.OUTPUT);
}

void draw()
{
  arduino.digitalWrite(ledPin, Arduino.HIGH);
  delay(1000);
  arduino.digitalWrite(ledPin, Arduino.LOW);
  delay(1000);
}
Advertisements