Arduino

Arduino Due ya disponible

arduinodue_front
Por fin esta disponible la Arduino Due, la placa de desarrollo mas potente de la linea Arduino. Esta placa esta basada en un microcontrolador SAM3X8E ARM CORTEX-M3 de la linea Atmel. Es la primer placa Arduino basada en un microcontrolador de 32 bits y cuenta con las siguientes características.

  • 54 entradas/salidas digitales (de las cuales 12 pueden ser usadas como salidas PWM),
  • 12 entradas analogicas,
  • 4 UART’s (puertos seriales por hardaware),
  • Frecuencia de reloj de 84MHz
  • Controlador USB OTG (On The Go)
  • 2 DAC (digital a analogico)
  • 2 TWI

La tarjeta contiene todo el sistema mínimo para que trabaje el microcontrolador, puede ser alimentado via USB, adaptador AC-DC o por batería. Es compatible con la mayoria de los shields que trabajan a 3.3V. Se debe tener en cuenta que el nuevo microcontrolador trabaja a 3.3V por lo que la tension maxima que pueden tolerar sus entradas es de 3.3V, una tension mayor a esta podria causar daños en la placa.

El cambio de 8 a 32 bits en el microcontrolador tiene los siguientes beneficios:

  • Un nucleo de 32 bits, permite realizar operaciones de 4 bytes en un solo ciclo del reloj del CPU
  • Reloj del CPU a 84 MHz
  • 512 KB de memoria de programa
  • Controlador DMA, que ayuda al CPU en tareas que requieren mucha memoria

[English version] Processing + Arduino + touchOSC

OSCgui

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 Schlegelwe 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

OSCgui
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:

(más…)

[Tutorial Arduino] Entradas/Salidas digitales

headt1

En el tutorial anterior describimos brevemente cual era la función de las entradas/salidas digitales, en este tutorial nos adentraremos en detalle de su funcionamiento y lo aplicaremos con un pequeño circuito, en el cual prenderemos leds dependiendo del estado de los pulsadores, para este circuito es necesario el siguiente material:

  • Arduino
  • Protoboard
  • 3 pulsadores (pushButton)
  • 3 leds (en mi caso usare un led RGB)
  • 3 resistencias 220 ohm
  • 3 resistencias 10 Kohm
  • cable

(más…)

Ir arriba