Entradas de Adrianmb
CoolTerm, Terminal de puerto serie multiplataforma
0
CoolTerm es una sencilla aplicación creada por Roger Meier que permite tener una terminal para nuestros puertos serie, su menú de configuración esta muy completo, permitiendo elegir desde una lista los puertos disponibles y seleccionar su velocidad y demás parámetros; despliega los datos recibidos tanto en ascii como en hexadecimal.
Sin duda una gran aplicación para los que hacemos uso de este protocolo constantemente para conexión del ordenador con microcontroladores, módulos usb-serial, gps, controladores de servos, etc. Lo mejor de todo esta bajo una licencia freeware y es multiplataforma.
Descargar desde la pagina oficial | freeware.the-meiers.org
[English version] Processing + Arduino + touchOSC
3
Today we will see how to communicate your mobile device android / iphone / iphone / iphone with our PC, through a protocol known as OSC (Open Sound Control) , this protocol is commonly used to control luminaires and devices such as strobes, sequencers and other things used in the musical world, one could say that is the replacement of the MIDI. OSCinternet protocol uses UDP for communication, which is why we need a requirement that the devices are on the same network, know your IP address and open a communication port.
Need for the next act: processing , arduino , LED RGB device TouchOSC installed. But we’ll do exactly?? … We will create a custom template with TouchOSC editor, which we use as a control to vary the intensity of an RGB LED and color combinations to create, we will open a communication link between processing and TouchOSC, finally send all information received to an Arduino board connected to the serial port and see the result obtained in the RGB LED at the end of all this we have the following result:
For start, the first thing to do is create our template for the TouchOSC and charge it to the device, for this we use the TouchOSC Editor a tool created by Hexl that you can download from here , we will use three fader controls with a resolution of one byte (0 – 255) to vary the intensity of the LED, for this follow the next steps in the video tutorial:
Now it’s time to open processing, but before you start throwing lines of code you need to install a specific library for communication with OSC, use the library oscP5 created by Andreas Schlegel, we can download it here, then decompress it and move its contents to documents / processing / libraries, once installed now open a new sketch.
We create a fader class that will be used as a control and to display the interaction with the mobile device, this control will be the closest thing to fader and with the same properties we use in our template, the final class for the Fader is as follows:
class Fader {
int val, valMap;
int px, py;
final int h=300, w=70;
color[] col;
color[] red= {
color(#DE1D2A), color(#131010), color(#501515)
};
color[] green= {
color(#3B811C), color(#111410), color(#25451A)
};
color[] blue= {
color(#1C2D81), color(#0D0D10), color(#0C1233)
};
Fader(int px, int py, char c) {
this.px=px;
this.py=py;
switch(c) {
case 'R':
col=red;
break;
case 'G':
col=green;
break;
case 'B':
col=blue;
break;
}
setValue(0);
}
void draw() {
strokeWeight(4);
strokeJoin(ROUND);
stroke(col[0]);
fill(col[1]);
rect(px, py, w, h);
fill(col[2]);
rect(px, py+(h-valMap), w, valMap);
if (mousePressed && (mouseX>=px && mouseX=py && mouseY< =py+h)) {
setValue((int)map((h-(mouseY-py)), 0, h, 0, 255));
}
}
void setValue(int val) {
this.val=val;
valMap=int(map(val, 0, 255, 0, h));
}
int getValue() {
return val;
}
}
After we create our custom template, for this we will use vectors with the addresses of each of our controls, these addresses are url type, we define this addresses in our template with the editor. The class of our template is as follows:
class RGBLayout {
//Define the addresses
//We defined it before in touchOSC Editor
//Addresses are url type /Page/Address
String[] Addr= {
"/RGB/fdrRed",
"/RGB/fdrGreen",
"/RGB/fdrBlue",
};
//create a vector to store recieved data
//creates as many variables as addresses have our templete
float[] Data= new float[Addr.length];
//by default touchOSC use the "f" typetag as identifier
String Typetag="f";
//this method check if the received data must be processed
void check(OscMessage theOscMessage) {
//for each address in our template
for (int i = 0; i 0) {
//read incoming byte
inByte = Serial.read();
//if the command expects a value
if (commandFlag){
//modify current led intensity
analogWrite(led[currLed],inByte);
//reset the flag and led indicator
commandFlag=false;
digitalWrite(ledCom, LOW);
}
//if expects a command
else
{
//select led to modify
//then make the command flag true
switch (inByte){
case 114://r ascii
currLed=0;
digitalWrite(ledCom, HIGH);
commandFlag=1;
break;
case 103://g ascii
currLed=1;
digitalWrite(ledCom, HIGH);
commandFlag=1;
break;
case 98://b ascii
currLed=2;
digitalWrite(ledCom, HIGH);
commandFlag=1;
break;
}
}
}
}
Post your comments and suggestions.
Processing + Arduino + touchOSC
4
Hoy veremos la forma de comunicar nuestro dispositivo móvil android/ipad/iphone/iphone con nuestra PC, por medio de un protocolo conocido como OSC (Open Sound Control), comúnmente este protocolo se utiliza para el control de luminaria y dispositivos como estrobos, secuenciadores y otras cosas usadas en el mundo musical, se podría decir que es el reemplazo del protocolo MIDI. OSC usa el protocolo de internet UDP para realizar la comunicación, por esa razón como requisito necesitamos que los dispositivos se encuentran en la misma red, conocer su dirección IP y abrir un puerto de comunicación.
Para el siguiente acto necesitaremos: processing, arduino, led RGB, dispositivo con touchOSC instalado. Pero que haremos exactamente??… Crearemos una plantilla personalizada con el touchOSC editor, la cual usaremos como control para variar la intensidad de un led RGB y poder crear combinaciones de colores, abriremos un enlace de comunicación entre processing y touchOSC, por ultimo mandaremos toda la informacion recibida a una placa arduino conectada por el puerto serie y veremos el resultado obtenido en el led RGB, al final de todo esto tendremos el siguiente resultado:




