Differences between revisions 1 and 35 (spanning 34 versions)
Revision 1 as of 2008-10-07 11:58:29
Size: 2605
Editor: dyn177231
Comment:
Revision 35 as of 2014-02-19 22:44:19
Size: 613
Editor: JunHu
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
<<TableOfContents>> #pragma section-numbers on
Line 3: Line 3:
== Arduino in Processing == The creapro java package ([[attachment:SoftwareDownloads/creapro.jar|creapro.jar]]) offers the library of classes and interfaces for controlling the AdMoVeo robot or the Arduino board within Processing. Read the following for more details:
Line 5: Line 5:
These functions are in the Processing Arduino Library and communicate (from Processing) with a Arduino, upon which the Firmata sketch has been installed.  * [[AdMoVeoInProcessing|AdMoVeo in Processing]]
 * [[ArduinoInProcessing|Arduino in Processing]]
 * Or you may read [[http://wiki.id.tue.nl/farm/documents/creapro/doc|the javadoc]] for a more formal documentation.
Line 7: Line 9:
 Arduino.list():: returns a list of the available serial devices. If your Arduino board is connected to the computer when you call this function, its device will be in the list.
 Arduino(parent, name, rate):: create an Arduino object. Parent should be "this" (without the quotes); name is the name of the serial device (i.e. one of the names returned by Arduino.list()); rate is the speed of the connection (115200 for the v2 version of the firmware, 57600 for v1). Note that in the v2 library, the rate parameter is optional.
 pinMode(pin, mode):: set a digital pin to input or output mode (Arduino.INPUT or Arduino.OUTPUT).
 digitalRead(pin):: returns the value of a digital pin, either Arduino.LOW or Arduino.HIGH (the pin must be set as an input).
 digitalWrite(pin, value):: writes Arduino.LOW or Arduino.HIGH to a digital pin.
 analogRead(pin):: returns the value of an analog input (from 0 to 1023).
 analogWrite(pin, value):: writes an analog value (PWM wave) to a digital pin that supports it (pins 3, 5, 6, 9, 10, and 11); value should be from 0 (always off) to 255 (always on).

== Example ==

{{{#!java
import processing.serial.*;
import nl.tue.id.creapro.*;

Arduino arduino;
int ledPin = 13;

void setup()
{
  println(Arduino.list());
  arduino = new Arduino(this, "COM3"); // v2
  //arduino = new Arduino(this, Arduino.list()[0], 57600); // v1
  delay(2000);
  arduino.pinMode(ledPin, Arduino.OUTPUT);
  delay(50);
  arduino.pinMode(11, Arduino.INPUT);
  delay(50);
  arduino.analogEnable(0);
  delay(50);
  arduino.setAnalogStep(4);
  delay(50);
  arduino.setAnalogPullRate(500);
  delay(50);
  println("Starting...");
// arduino.clearCommandCount();
 (new Repeat()).start();
 delay(100);

  noLoop();
}

void draw()
{
}

void digitalAvailable11(int o, int n){
  println(n);
}

void analogAvailable0(int o, int n){
  println(n);
}

class Repeat extends Thread{
  public void run(){
    arduino.clearCommandCount();
      for (int i=0; i<8; i++){
  arduino.digitalWrite(ledPin, Arduino.HIGH);
  try{sleep(400);}catch(Exception e){}
  arduino.digitalWrite(ledPin, Arduino.LOW);
  try{sleep(400);}catch(Exception e){} }
  try{sleep(2000);}catch(Exception e){}
    arduino.reportCommandCount();
    arduino.reportCommandCount();
    arduino.reportCommandCount();
    arduino.reportCommandCount();
  }
  
}
}}}
Following [[SoftwareEnvironment#creapro|this link]], you can find the instructions for installing the creapro package.

The creapro java package (creapro.jar) offers the library of classes and interfaces for controlling the AdMoVeo robot or the Arduino board within Processing. Read the following for more details:

Following this link, you can find the instructions for installing the creapro package.

CreaPro: CreaproProcessingLibrary (last edited 2014-02-19 22:44:19 by JunHu)