Sketch de Processing para Arduino

import processing.serial.*;
  
import processing.sound.*;
SoundFile file;

import processing.pdf.*;// libreria para imprimir dibujo en un pdf
import cc.arduino.*; // reference the arduino library
import processing.serial.*; // reference the serial library
Arduino arduino; // create a variable arduino of the Arduino data type

float ejex = 700;
float yoff = 0.0;

void setup() {
 size(1000, 800);
 background (60);
 smooth();
 beginRecord(PDF, "montanas.pdf");
println(Serial.list()); // List all the available serial ports:
arduino = new Arduino(this, Arduino.list()[5], 57600); //declaracion de instancia arduino

file = new SoundFile(this, "audio.wav");
  file.play();
}

void draw() {
 fill(44, 185, 147 +(arduino.analogRead(0)*0.1), 10);
  // Draw the shape
  stroke(200, 100);
 beginShape();
 float xoff = 0;
 for (float x = 0; x <= width; x += 10) {
  float y = map(noise(xoff, yoff), 0, 1, arduino.analogRead(1), ejex);
  vertex(x,y);
  xoff += 0.05;
  } 
  yoff += 0.01;
  vertex(width, height);
  vertex(0, height);
  endShape(CLOSE);
}

0 comentarios:

Publicar un comentario