Tutorial.PhysicalPixel History

Hide minor edits - Show changes to markup

June 12, 2010, at 02:37 PM by Equipo Traduccion -
Changed lines 5-8 from:

Un ejemplo de como usar la placa Arduino para recibir datos de un ordenador. En este caso la placa Arduino enciende un LED cuando recibe el caracter 'H' y lo apaga cuando recibe el caracter 'L'.

Los datos son enviados por el monitor serie de Arduino, o por otro programa como Precessing (ver el código mas adelante), Flash (a través de un proxy serial-net), PD, o Max/MSP.

to:

éste es un ejemplo de cómo usar la placa Arduino para recibir datos desde un ordenador. En este caso la placa Arduino enciende un LED cuando recibe el caracter 'H' y lo apaga cuando recibe el caracter 'L'.

Los datos son enviados por el monitor serie de Arduino, o por otro programa como Processing (ver el código más adelante), Flash (a través de un proxy serial-net), PD, o Max/MSP.

Changed line 13 from:

clicar la imagen para agrandarla.

to:

pinchar sobre la imagen para agrandarla.

Changed line 22 from:

clicar la imagen para agrandarla.

to:

pinchar sobre la imagen para agrandarla.

Changed lines 111-112 from:

Tal como el ratón se mueve desde el cuadrado centra el LED del pin 13 debe encenderse o apagarse. El applet de Processing tiene una apariencia como esta:

to:

Cuando el ratón se mueve desde el cuadrado central el LED conectado al pin 13 debe encenderse o apagarse. El applet de Processing tiene uesta apariencia:

Changed lines 117-118 from:

El diagrama en Max/MSP tiene un aspecto como el de la siguiente imagen. El texto del esquema está unido a la imagen, por lo que solo tienes que copiar/pegar en una nueva ventana de esquema.

to:

El diagrama en Max/MSP tiene un aspecto como el de la siguiente imagen. El texto del esquema está unido a la imagen, por lo que sólo tienes que copiar/pegar en una nueva ventana de esquema.

June 09, 2010, at 11:58 AM by Equipo Traduccion -
Changed lines 109-111 from:

Output

As you mouse over the center square, the LED on pin 13 should turn on and off. The Processing applet looks like this:

to:

Salida.

Tal como el ratón se mueve desde el cuadrado centra el LED del pin 13 debe encenderse o apagarse. El applet de Processing tiene una apariencia como esta:

Changed lines 115-117 from:

Max patch

The Max/MSP patch looks like the image below. The text of the patch is linked behind the image. Copy it and paste it into a new patch window.

to:

Diagrama Max.

El diagrama en Max/MSP tiene un aspecto como el de la siguiente imagen. El texto del esquema está unido a la imagen, por lo que solo tienes que copiar/pegar en una nueva ventana de esquema.

June 09, 2010, at 11:48 AM by Equipo Traduccion -
Changed lines 1-13 from:

Examples > Communication

Physical Pixel

An example of using the Arduino board to receive data from the computer. In this case, the Arduino boards turns on an LED when it receives the character 'H', and turns off the LED when it receives the character 'L'.

The data can be sent from the Arduino serial monitor, or another program like Processing (see code below), Flash (via a serial-net proxy), PD, or Max/MSP.

Circuit

An LED on pin 13.

click the image to enlarge

to:

Ejemplos > Comunicación

Pixel físico.

Un ejemplo de como usar la placa Arduino para recibir datos de un ordenador. En este caso la placa Arduino enciende un LED cuando recibe el caracter 'H' y lo apaga cuando recibe el caracter 'L'.

Los datos son enviados por el monitor serie de Arduino, o por otro programa como Precessing (ver el código mas adelante), Flash (a través de un proxy serial-net), PD, o Max/MSP.

Circuito.

Un LED en el pin 13.

clicar la imagen para agrandarla.

Changed lines 16-21 from:

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Schematic

click the image to enlarge

to:

imagen generada usando Fritzing. Para mas circuitos de ejemplo ver página de proyectos de Fritzing

Esquema.

clicar la imagen para agrandarla.

Changed line 27 from:

Code

to:

Código.

Changed lines 35-36 from:

Processing Code

to:

Código para Processing.

February 23, 2010, at 11:30 PM by Tom Igoe -
Changed lines 29-50 from:
 /*
   Physical Pixel
  
  An example of using the Arduino board to receive data from the 
  computer.  In this case, the Arduino boards turns on an LED when
  it receives the character 'H', and turns off the LED when it
  receives the character 'L'.
  
  The data can be sent from the Arduino serial monitor, or another
  program like Processing (see code below), Flash (via a serial-net
  proxy), PD, or Max/MSP.
  
  The circuit:
  * LED connected from digital pin 13 to ground
  
  created 2006
  by David A. Mellis
  modified 14 Apr 2009
  by Tom Igoe and Scott Fitzgerald
  
  http://www.arduino.cc/en/Tutorial/PhysicalPixel
  */
to:
Deleted lines 30-55:
 const int ledPin = 13; // the pin that the LED is attached to
 int incomingByte;      // a variable to read incoming serial data into

 void setup() {
   // initialize serial communication:
   Serial.begin(9600);
   // initialize the LED pin as an output:
   pinMode(ledPin, OUTPUT);
 }

 void loop() {
   // see if there's incoming serial data:
   if (Serial.available() > 0) {
     // read the oldest byte in the serial buffer:
     incomingByte = Serial.read();
     // if it's a capital H (ASCII 72), turn on the LED:
     if (incomingByte == 'H') {
       digitalWrite(ledPin, HIGH);
     } 
     // if it's an L (ASCII 76) turn off the LED:
     if (incomingByte == 'L') {
       digitalWrite(ledPin, LOW);
     }
   }
 }
Added line 33:
Changed lines 48-49 from:
to:

// This example code is in the public domain.

August 27, 2009, at 08:56 PM by Tom Igoe -
Added lines 16-18:

image developed using Fritzing. For more circuit examples, see the Fritzing project page

July 05, 2009, at 07:37 PM by Tom Igoe -
Changed lines 24-78 from:
to:
Changed lines 80-111 from:

const int ledPin = 13; // the pin that the LED is attached to int incomingByte; // a variable to read incoming serial data into

void setup() {

  // initialize serial communication:
  Serial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);

}

void loop() {

  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it's a capital H (ASCII 72), turn on the LED:
    if (incomingByte == 'H') {
      digitalWrite(ledPin, HIGH);
    } 
    // if it's an L (ASCII 76) turn off the LED:
    if (incomingByte == 'L') {
      digitalWrite(ledPin, LOW);
    }
  }

}

@]

Processing Code

[@

to:
June 25, 2009, at 11:26 PM by Tom Igoe -
June 25, 2009, at 11:07 PM by Tom Igoe -
Changed lines 19-22 from:
to:

June 25, 2009, at 11:07 PM by Tom Igoe -
Changed lines 19-22 from:
to:
June 25, 2009, at 11:06 PM by Tom Igoe -
Changed line 13 from:

click the image to enlarge

to:

click the image to enlarge

Changed lines 16-17 from:
to:

Schematic

click the image to enlarge Attach:blink_schem.png Δ Δ

June 25, 2009, at 11:05 PM by Tom Igoe -
Changed line 21 from:
  1. define ledPin 13 // the pin that the LED is attached to
to:

const int ledPin = 13; // the pin that the LED is attached to

April 16, 2009, at 07:57 PM by Tom Igoe -
Changed lines 10-11 from:
to:
Added lines 13-17:

click the image to enlarge

April 16, 2009, at 12:02 AM by Tom Igoe -
Changed lines 10-11 from:
to:
Changed lines 17-21 from:

int outputPin = 13; int val;

void setup() {

to:
  1. define ledPin 13 // the pin that the LED is attached to

int incomingByte; // a variable to read incoming serial data into

void setup() {

  // initialize serial communication:
Changed lines 23-24 from:
  pinMode(outputPin, OUTPUT);
to:
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
Changed lines 27-32 from:

void loop() {

  if (Serial.available()) {
    val = Serial.read();
    if (val == 'H') {
      digitalWrite(outputPin, HIGH);
to:

void loop() {

  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it's a capital H (ASCII 72), turn on the LED:
    if (incomingByte == 'H') {
      digitalWrite(ledPin, HIGH);
Changed lines 36-37 from:
    if (val == 'L') {
      digitalWrite(outputPin, LOW);
to:
    // if it's an L (ASCII 76) turn off the LED:
    if (incomingByte == 'L') {
      digitalWrite(ledPin, LOW);
Added line 42:
Added line 48:
Changed lines 50-51 from:

// by BARRAGAN <http://people.interaction-ivrea.it/h.barragan>

to:
Changed line 52 from:

// turn ON a light if the mouse is over a rectangle and turn it off

to:

// turn ON a light if the mouse is over a square and turn it off

Changed lines 54-56 from:

// created 13 May 2004

to:

// created 2003-4 // based on examples by Casey Reas and Hernando Barragan // modified 18 Jan 2009 // by Tom Igoe

Changed lines 62-67 from:
to:

float boxX; float boxY; int boxSize = 20; boolean mouseOverBox = false;

Changed lines 69-75 from:

void setup() {

  size(200, 200); 
  noStroke(); 
  frameRate(10); 
to:

void setup() {

  size(200, 200);
  boxX = width/2.0;
  boxY = height/2.0;
  rectMode(RADIUS); 
Changed line 81 from:
to:
Changed lines 85-88 from:

}

// function to test if mouse is over square boolean mouseOverRect()

to:

}

void draw()

Changed lines 90-102 from:
  return ((mouseX >= 50)&&(mouseX <= 150)&&(mouseY >= 50)&(mouseY <= 150)); 

}

void draw() {

  background(#222222); 
  if(mouseOverRect())      // if mouse is over square 
  { 
    fill(#BBBBB0);         // change color 
    port.write('H');       // send an 'H' to indicate mouse is over square 
  } else { 
    fill(#666660);         // change color 
    port.write('L');       // send an 'L' otherwise 
to:
  background(0);

  // Test if the cursor is over the box 
  if (mouseX > boxX-boxSize && mouseX < boxX+boxSize && 
    mouseY > boxY-boxSize && mouseY < boxY+boxSize) {
    mouseOverBox = true;  
    // draw a line around the box and change its color:
    stroke(255); 
    fill(153);
    // send an 'H' to indicate mouse is over square:
    port.write('H');       
Changed lines 102-104 from:
  rect(50, 50, 100, 100);  // draw square 

} @]

to:
  else {
    // return the box to it's inactive state:
    stroke(153);
    fill(153);
    // send an 'L' to turn the LED off: 
    port.write('L');      
    mouseOverBox = false;
  }

  // Draw the box
  rect(boxX, boxY, boxSize, boxSize);

}

@]

Output

As you mouse over the center square, the LED on pin 13 should turn on and off. The Processing applet looks like this:

Max patch

The Max/MSP patch looks like the image below. The text of the patch is linked behind the image. Copy it and paste it into a new patch window.

April 11, 2007, at 05:12 PM by David A. Mellis -
Added lines 1-91:

Examples > Communication

Physical Pixel

An example of using the Arduino board to receive data from the computer. In this case, the Arduino boards turns on an LED when it receives the character 'H', and turns off the LED when it receives the character 'L'.

The data can be sent from the Arduino serial monitor, or another program like Processing (see code below), Flash (via a serial-net proxy), PD, or Max/MSP.

Circuit

An LED on pin 13.

Code

int outputPin = 13;
int val;

void setup()
{
  Serial.begin(9600);
  pinMode(outputPin, OUTPUT);
}

void loop()
{
  if (Serial.available()) {
    val = Serial.read();
    if (val == 'H') {
      digitalWrite(outputPin, HIGH);
    } 
    if (val == 'L') {
      digitalWrite(outputPin, LOW);
    }
  }
}

Processing Code

// mouseover serial 
// by BARRAGAN <http://people.interaction-ivrea.it/h.barragan> 

// Demonstrates how to send data to the Arduino I/O board, in order to 
// turn ON a light if the mouse is over a rectangle and turn it off 
// if the mouse is not. 

// created 13 May 2004 

import processing.serial.*; 

Serial port; 

void setup() 
{ 
  size(200, 200); 
  noStroke(); 
  frameRate(10); 

  // List all the available serial ports in the output pane. 
  // You will need to choose the port that the Arduino board is 
  // connected to from this list. The first port in the list is 
  // port #0 and the third port in the list is port #2. 
  println(Serial.list()); 

  // Open the port that the Arduino board is connected to (in this case #0) 
  // Make sure to open the port at the same speed Arduino is using (9600bps) 
  port = new Serial(this, Serial.list()[0], 9600); 
} 

// function to test if mouse is over square 
boolean mouseOverRect() 
{ 
  return ((mouseX >= 50)&&(mouseX <= 150)&&(mouseY >= 50)&(mouseY <= 150)); 
} 

void draw() 
{ 
  background(#222222); 
  if(mouseOverRect())      // if mouse is over square 
  { 
    fill(#BBBBB0);         // change color 
    port.write('H');       // send an 'H' to indicate mouse is over square 
  } else { 
    fill(#666660);         // change color 
    port.write('L');       // send an 'L' otherwise 
  } 
  rect(50, 50, 100, 100);  // draw square 
} 

Share