Cintillo Institucional
Diferencias entre las revisiones 7 y 8
Versión 7 con fecha 2009-05-12 21:29:23
Tamaño: 2890
Comentario:
Versión 8 con fecha 2009-05-12 21:30:23
Tamaño: 2898
Comentario:
Los textos eliminados se marcan así. Los textos añadidos se marcan así.
Línea 14: Línea 14:
Programa Processing para Osciloscopio
Línea 15: Línea 16:
Programa Processing para Osciloscopio
Línea 17: Línea 17:
Línea 21: Línea 20:
 *   *
Línea 24: Línea 23:
 *   *
Línea 31: Línea 30:
 *   *
Línea 36: Línea 35:
 *   *
Línea 46: Línea 45:
void setup()  void setup()
Línea 72: Línea 71:
    line(width-x, height-1-getY(values[x-1]),      line(width-x, height-1-getY(values[x-1]),
Línea 78: Línea 77:
Manero Puerto serie, Osciloscopio.
Línea 79: Línea 79:




Manero Puerto serie, Osciloscopio.
Programa Arduino Ocili

wiki comunidad

Proyecto Hardware Libre Cenditel

Página Cenditel

wiki Cenditel

Plataforma de Desarrollo Colaborativo

Curso Sensibilización Hardware Libre (Unidad 002)

logohl.png logohl.png logohl.png

003/01 Actividad 005

Manero Puerto serie, Osciloscopio.

Programa Processing para Osciloscopio

/*
 * Oscilloscope
 * Gives a visual rendering of analog pin 0 in realtime.
 *
 * This project is part of Accrochages
 * See http://accrochages.drone.ws
 *
 * (c) 2008 Sofian Audry (info@sofianaudry.com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
import processing.serial.*;

Serial port;  // Create object from Serial class
int val;      // Data received from the serial port
int[] values;

void setup()
{
  size(640, 480);
  // Open the port that the board is connected to and use the same speed (9600 bps)
  port = new Serial(this, Serial.list()[0], 9600);
  values = new int[width];
  smooth();
}

int getY(int val) {
  return (int)(val / 1023.0f * height) - 1;
}

void draw()
{
  while (port.available() >= 3) {
    if (port.read() == 0xff) {
      val = (port.read() << 8) | (port.read());
    }
  }
  for (int i=0; i<width-1; i++)
    values[i] = values[i+1];
  values[width-1] = val;
  background(350);
  stroke(255);
  for (int x=1; x<width; x++) {
    line(width-x,   height-1-getY(values[x-1]),
    width-1-x, height-1-getY(values[x]));
  }
}

Manero Puerto serie, Osciloscopio.

Programa Arduino Ocili

hlpd/curso_arduino/uni00301 (última edición 2011-06-13 21:58:17 efectuada por _desactivada_csoto)