Arduino

I was able to use the Serial IO patch with my Arduino (http://www.arduino.cc/) to send a string to it and control an LED on/off, but I wasn't able to use the analog output to control the intensity of the light.

So that got me thinking that maybe you could make an Arduino patch that would make it easy to work with it from QC. I think that your best bet would be to use the Firmata firmware.

http://www.arduino.cc/playground/Interfacing/Firmata

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

cwright's picture
failure

How does it fail? Maybe it's a design flaw/implementation flaw in the Serial patch?

I'm a bit hesitant to commit to making another patch I cannot test (no Arduino available around here), but I think it would make things simpler overall, if done well.

how protocol-compatible are the different firmwares? (I know next to nothing about these, except for what I've briefly read on the website)

waxtastic's picture
arduino

I don't really know about the protocols. I'm just a beginner with Arduino and wanted to see if I could use it with QC. I got this example working http://www.arduino.cc/en/Tutorial/PhysicalPixel with the serial patch but this one didn't http://www.arduino.cc/en/Tutorial/Dimmer

Here is the code in Arduino:

int ledPin = 9;
int val;

void setup()
{
  // begin the serial communication
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop()
{


  // check if data has been sent from the computer
  if (Serial.available()) {
    // read the most recent byte (which will be from 0 to 255)
    val = Serial.read();
    // set the brightness of the LED
    analogWrite(ledPin, val);
  }
}

In QC I'm just using a input splitter for the Data source and an LFO is connected to the Send Signal. It's definitely connecting with the Arduino board, but the LED is not affected by the data.

I guess the issue is that the serial patch only sends strings and the analog out in Arduino uses bytes. There might be some really simple solution for this, but I'm not smart enough to figure it out.

cwright's picture
You're right - binary data needed

After looking over the code a bit, I'm pretty sure you're right; it's a matter of sending bytes vs. strings (which are also bytes, but not as directly accessible as such).

So, it looks like we're in need of some binary data manipulation tools. Any ideas on how this should be implemented to be useful? We could add some index inputs to the serial sender to send raw bytes with a specified value, but that would be cumbersome for lots of data. An alternative would be to make a Binary Data port type (this has been discussed very limitedly, perhaps it's time for a full-blown discussion?).

I'm up for ideas; This doesn't look too difficult to solve, and would open up a lot of additional possibilities (DMX would use this too, in the very near future)

sbn..'s picture
I can try

I'll try this at some point, since I have an Arduino I use in a custom VJ controller. Any chance you could make your QC patch available online?

I just built a midi out for the Arduino (about three components) and route it in through a midi interface, but midi is restricted to 7 bit controller values (0-127), and the ADC in the Arduino can read 10 bits (0-1024), so if we could get this to work I'd consider moving to serial.

tobyspark's picture
also arduino'd

firmata is imho definitely the way to go for an arduino node. it exposes all the i/o functionality of the arduino to the host software. just a bitch none of the existing hosts fit with qc.

i'll be willing to help code this if i have a proper project that actually requires the arduino.

toby

VJ_Anomolee's picture
QC firmata

heya, Any more developments on the quartz to firmata front??? I am VERY interested. Im working on a cool project right now to create a 3D interface for moving models around in quartz.

Please oh please oh please Can some one help me with an Arduino to Quartz Composer patch? I cant find the Kineme serial patch anywhere on this site! Anyone know where to find it?

cwright's picture
beta-serial

The serial patch is still in beta (because everyone has a different experience with it, and I don't know why) so to access it you'll need to check the "I would like to beta test new and updated patches." box in your user profile. Then, head over to http://kineme.net/SerialIOPatch20080319beta

videmaniacs's picture
Re: Arduino

Hi also want to second this feature request. Would be great if we can make QC become connected to the outside of the PC environment either via Arduino or also via phidgets :-))

waxtastic's picture
Re: Arduino

The Serial IO Beta patch works very well for Arduino analog and digital input (sensors, buttons etc.) You can download an example here http://mansteri.com/2008/11/arduino-quartz-composer/

Only the output (servos, LEDs etc.) is problematic. Apparently there are some problems with the FTDI drivers. You can read all about it on the Serial IO discussion. It's very weird, because the first time I used it on this computer, I was able to get it working (turning an LED on/off with the keyboard), but then it suddenly stopped working and I haven't been able to use it at all after that. Even with the exact same code I used before.

seejordan's picture
Re: Arduino

Hey All,

I've been trying to get this to work as well. Downloaded the latest FTDI drivers, etc. I can get all the inputs working fine, but no luck with sending.

My arduino code is below. As you can see, it should turn the LED on if it gets ANYTHING from from the serial connection. But, using the SerialIO patch in QC won't get it to signal.

I've put the Firmata code on the arduino, and tested it with Processing; which works great on ALL in's and outs. But, can't get the SerialIO to send.

I've read all about the binary/javascript issues, and have tried some things with this, but a simple example with working QC/SerialIO would be really helpful.

Anyone have an example? Or, even better, an example QC patch that uses the Firmata code?

Thanks, Cj

const int ledPin = 13; // the pin that the LED is attached to
int in1;      // a variable to read incoming serial data into
 
void setup() {
  // initialize serial communication:
  Serial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
}
 
void loop() {
  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    digitalWrite(ledPin, HIGH);
    delay(200); 
    digitalWrite(ledPin, LOW);
 
    Serial.println("YES");  
    // read the oldest byte in the serial buffer:
    in1 = Serial.read();
    // if it's a capital H (ASCII 72), turn on the LED:
    if (in1 == '1') {
      digitalWrite(ledPin, HIGH);
      Serial.println("ON");  
      delay(200);                  // waits for a second
    } 
    // if it's an L (ASCII 76) turn off the LED:
    if (in1 == '2') {
      digitalWrite(ledPin, LOW);
      Serial.println("OFF");  
      delay(200);                  // waits for a second
    }
  }
}

ayalacortes's picture
Re: Arduino

Try this one. It is a simple QC with two serial output patches (and a sprite for feedback). Paste the included code in your arduino and start the serial monitor just to make sure the thing is running. In QC push the up/down arrows of your keyboard to turn on/off the LED on your arduino.

Somehow QC sends signal. Try also deleting the second SerialI/O patch and pasting it again.

I can't say the thing actually "works" as it should but there is signal passing by.

Tip: in the arduino serial monitor send '1' or '0' to wake up the communication. You may simply send an initial value before the loop.

Juan

PreviewAttachmentSize
SerialReceiverTest.qtz4.75 KB

monobrau's picture
Re: Arduino

I've got this working, but only after a quit and restart of QC. If you stop and start the composition it only works the very first time it seems...

It also only works when the serial monitor from the arduino app is active, and with one send patch it still works as well.

waxtastic's picture
Re: Arduino

I just got a serial plugin working that is more reliable than the kineme serial out. I modified this one http://www.planetclegg.com/projects/QC-Peggy.html

It seems to work pretty nicely when sending single characters to Arduino. I still need to polish it a bit before releasing it out there, but email me if you need the plugin.

m at mansteri dot com

waxtastic's picture
Re: Arduino

Oh well, I was celebrating too early. It seems that I'm also running into the same issue as the Kineme Serial Output patch.

from here: http://kineme.net/SerialIOPatch20080326beta

Quote:
The problem is basically this: Opening the serial port but never reading from it eventually causes some buffer overflows in the kernel. This causes some annoying side effects if you don't catch it soon enough. So if you have a Serial Output patch in the composition, you should add a matching Serial Input patch (with a specified break string!), and send its output to some red patch (a zero-count iterator is a cheap data sink). This will cause it to read out the buffer, averting the potential overflow (which shouldn't happen anyway).

My plugin works quite well as long as you also have a Serial Input Patch connected somewhere in your composition.

It does fix the strange issues with the Kineme Serial Output where you would have to open the Arduino serial monitor to get the patch to output anything. You can also start and stop the composition and the patch should still work.

Here's the download link if someone's interested: http://mansteri.com/download/software/serial/MonsteriSerialOutBeta.zip

ayalacortes's picture
Re: Arduino

Thanks a lot. It works here and I can shutdown the arduino app as well. I was getting used to push-start the patch from the serial monitor ! (still doesn't survive if I stop the viewer but it is a lot more responsive)

update: It actually does survive the stop/start but I noticed the arduino app should be off. So... upload the code, quit the app and start QC. then it works.

juan

dust's picture
Re: Arduino

ohh sweet waxtastic i'm working on a xbee project and was going to try and incorporate qc somehow, maybe as multipoint aggregate or visual interface for xbee. when i get to the visual part i will give your plug a try.

Hornet_C's picture
Re: Arduino

Is it right, that your plugin just sends the ASCII code of the first digit or letter used in "Data" ?

waxtastic's picture
Re: Arduino

that's right. so not really useful for everything. I never had the time to work any more on this as I only needed to send single characters.