Processing

From air
Revision as of 16:10, 8 February 2011 by Donsez (talk | contribs)
Jump to navigation Jump to search

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.*;

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();
  }
}



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);
}