Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Se utiliza las librerias ControlP5 y Serial del Processing
- import controlP5.*;
- import processing.serial.*;
- // Se define la variable cP5 del tipo ControlP5
- ControlP5 cP5;
- // Se le da nombres a los dos Slider y al Serial
- Slider SliON;
- Slider SliOFF;
- Serial serial;
- // Configuración inicial
- void setup() {
- size(610, 400); //Tamaño de la ventana
- cP5 = new ControlP5(this); //Crea el objeto ControlP5
- // Crea el Slider del Tiempo Encendido
- SliON = cP5.addSlider("O")
- .setRange(0, 1000)
- .setValue(100)
- .setPosition(60, 150)
- .setSize(300, 30)
- .setNumberOfTickMarks(20)
- .setLabelVisible(false)
- .setColorForeground(color(255, 0, 0))
- .setColorBackground(color(0))
- .setColorActive(color(255, 255, 0))
- ;
- // Crea el Slider del Tiempo Apagado
- SliOFF = cP5.addSlider("F")
- .setRange(0, 1000)
- .setValue(100)
- .setPosition(60, 250)
- .setSize(300, 30)
- .setNumberOfTickMarks(20)
- .setLabelVisible(false)
- .setColorForeground(color(255, 0, 0))
- .setColorBackground(color(0))
- .setColorActive(color(255, 255, 0))
- ;
- String puerto = Serial.list()[1];
- serial = new Serial(this, puerto, 9600);
- }
- // Se dibuja cada frame
- void draw() {
- background(0xFF444444); //Color Gris del fondo
- fill(10);
- rect(35, 125, 380, 100);
- fill(0, 225, 0);
- rect(45, 135, 360, 80);
- fill(10);
- rect(35, 225, 380, 100);
- fill(0, 225, 0);
- rect(45, 235, 360, 80);
- fill(50, 255, 255);
- textFont(createFont("Gill Sans Ultra Bold", 50));
- text("TIEMPO DE:", 130, 100);
- fill(50, 255, 255);
- textSize(20);
- text("ENCENDIDO", 420, 170);
- fill(50, 255, 255);
- textSize(20);
- text("APAGADO", 420, 270);
- fill(0, 0, 0);
- textSize(20);
- text("(OFF)", 460, 300);
- fill(0, 225, 0);
- textSize(20);
- text("(0N)", 460, 200);
- fill(225, 0, 0);
- textSize(15);
- text("0", 55, 200);
- fill(255, 0, 0);
- textSize(15);
- text("1000", 330, 200);
- fill(255, 0, 0);
- textSize(15);
- text("0", 55, 300);
- fill(255, 0, 0);
- textSize(15);
- text("1000", 330, 300);
- fill(0, 225, 0);
- textSize(25);
- text("LUIS MIGUEL TORRES ARTUNDUAGA", 10, 370);
- }
- // Como se va actuar cuando ocurra un evento con los Slider
- void controlEvent(ControlEvent evento) {
- String nombre = evento.getController().getName();
- int valor = int(evento.getController().getValue());
- serial.write(nombre + valor);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement