juberth

Untitled

Sep 5th, 2013
1,435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.56 KB | None | 0 0
  1.  import controlP5.*;        
  2. import processing.serial.*;  
  3. ControlP5 cp5;                
  4. Knob rojo, verde, azul;        
  5. Textlabel texto1, texto2, texto3, texto4, texto5, texto6;
  6. Serial serial;                
  7.  
  8. void setup()
  9. {
  10. serial = new Serial(this, Serial.list()[0],9600);  
  11. String puerto = Serial.list()[0];                  
  12. size(620,400);                      
  13. cp5 = new ControlP5(this);        
  14.  
  15.  
  16. rojo = cp5.addKnob("R",0,255,0,70,120,100);
  17. rojo.setColor(new CColor(0xFFff0000,0xFF9f9f00,0xFF5f0000,0xFFFFFFFF,0xFFFFFFFF));
  18.  
  19.  
  20. verde = cp5.addKnob("G",0,255,0,260,120,100);
  21. verde.setColor(new CColor(0xFF00FF00,0xFF9f9f00,0xFF005F00,0xFFFFFFFF,0xFFFFFFFF));
  22.  
  23.  
  24. azul = cp5.addKnob("B",0,255,0,450,120,100);
  25. azul.setColor(new CColor(0xFF0000ff,0xFF9f9f00,0xFF00005f,0xFFFFFFFF,0xFFFFFFFF));
  26.  
  27.  
  28. texto1 = cp5.addTextlabel("label")
  29.                     .setText("CONTROL DE LED RGB")
  30.                     .setPosition(25,48)
  31.                     .setColorValue(0xffff0000)
  32.                     .setFont(createFont("Ravie",30))
  33.                     ;
  34.                    
  35. texto2 = cp5.addTextlabel("label1")
  36.                     .setText("AZUL")
  37.                     .setPosition(475,235)
  38.                     .setColorValue(0xffff0000)
  39.                     .setFont(createFont("Comic Sans MS",15))
  40.                     ;              
  41.    
  42. texto3 = cp5.addTextlabel("label2")
  43.                     .setText("VERDE")
  44.                     .setPosition(280,235)
  45.                     .setColorValue(0xffff0000)
  46.                     .setFont(createFont("Comic Sans MS",15))
  47.                     ;
  48.                    
  49. texto4 = cp5.addTextlabel("label3")
  50.                     .setText("ROJO")
  51.                     .setPosition(95,235)
  52.                     .setColorValue(0xffff0000)
  53.                     .setFont(createFont("Comic Sans MS",15))
  54.                     ;              
  55.  
  56.  
  57. texto4 = new Textlabel(cp5,"Estudiante: Juberth Andres Renteria",40,280,600,200);  
  58. texto4.setFont(createFont("MV Boli",15));
  59. texto5 = new Textlabel(cp5,"Ingenieria Electronica",40,295,600,200);  
  60. texto5.setFont(createFont("MV Boli",15));
  61. texto6 = new Textlabel(cp5,"Noveno semestre",40,310,600,200);  
  62. texto6.setFont(createFont("MV Boli",15));
  63. }
  64.  
  65. void draw()
  66. {
  67. background(100,70,20);  
  68.  texto4.draw(this);  
  69.  texto5.draw(this);
  70.  texto6.draw(this);
  71. }
  72.  
  73. void controlEvent (ControlEvent evento)
  74. {
  75. String nombre = evento.getController().getName();  
  76. int valor = int(evento.getController().getValue());  
  77. serial.write(nombre + ":" + valor);  
  78. println(nombre + ":" + valor);  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment