Difference between revisions of "Processing"
Jump to navigation
Jump to search
Line 6: | Line 6: | ||
Exemple: |
Exemple: |
||
− | <pre> |
||
− | import processing.serial.*; |
||
− | |||
− | Serial myPort; |
||
− | char send_char; |
||
− | String portName; |
||
− | void setup() |
||
− | { |
||
− | size(490, 200); |
||
− | background(51); |
||
− | frame.setResizable(true); |
||
− | println(Serial.list()); |
||
− | String portName = Serial.list()[3]; |
||
− | myPort = new Serial(this, portName, 115200); |
||
− | } |
||
− | |||
− | void draw() |
||
− | { myPort.clear(); |
||
− | new Serial(this, portName, 115200); |
||
− | send_char='Q'; |
||
− | myPort.write(send_char); // envoi un caractere a l'arduino |
||
− | while (myPort.available() > 0) { |
||
− | String inBuffer = myPort.readString(); |
||
− | if (inBuffer != null) { |
||
− | print (send_char+" "); |
||
− | println(inBuffer); |
||
− | } |
||
− | myPort.clear(); |
||
− | } |
||
− | new Serial(this, portName, 115200); |
||
− | send_char='L'; |
||
− | myPort.write(send_char); // envoi un caractere a l'arduino |
||
− | while (myPort.available() > 0) { |
||
− | String inBuffer = myPort.readString(); |
||
− | if (inBuffer != null) { |
||
− | print (send_char+" "); |
||
− | println(inBuffer); |
||
− | } |
||
− | myPort.clear(); |
||
− | } |
||
− | } |
||
− | </pre> |
||
− | |||
− | |||
− | |||
− | |||
<pre> |
<pre> |
Revision as of 18:13, 8 February 2011
Processing est un environnement de développement d'animation en Java simple à mettre en oeuvre.
Processing.JS est l'adaptation en Javascript de Processing.
Un programme Processing et une application Web Processing.js peuvent échanger des informations avec des cartes Arduino connectées à l'hôte (plus...).
Exemple:
import processing.serial.*; import cc.arduino.*; Arduino arduino; int ledPin = 13; void setup() { //println(Arduino.list()); arduino = new Arduino(this, Arduino.list()[0], 57600); arduino.pinMode(ledPin, Arduino.OUTPUT); } void draw() { arduino.digitalWrite(ledPin, Arduino.HIGH); delay(1000); arduino.digitalWrite(ledPin, Arduino.LOW); delay(1000); }