For loop in 1 frame

Hi vvvvusers,

is it possible to create a loop which work very fast. In one frame exactly.

I’m using arduino and I need to send 64 data per frames to control 64 leds.

If I use a counter(animation) to make the loop, it takes around one second to update all the leds… it’s too slow.

Thank you.

sadly i still do not have experience with the arduino.
but did you try using FrameCounter (Animation) ?

together with setting the Time Mode-pin of a MainLoop (VVVV)
to “Filtered” (or even “Increment” ?!?) you should have the framerate under quite precise control.

You send you data all in 1 vvvv go and let the Arduino handle the sift registers right?

I mean, you should just generate one String, with all 64 LED info’s, and send that, at at least 30 frame/sec (or something) and let the Arduino worry about the timing.

If you can show me your patch and or code, I really think you don’t need that vvvv loop you are asking.

Hi,

I try this solution, but the problem is that vvvv send a string, but the serial.Read() fonction from arduino return an int …

So, if I send sixty four 0 or 1 from vvvv in the same string when I’m in arduino I can’t get this as an integer and can’t do a for loop.

This is because my idea was to create the for loop inside vvvv, to send to arduino all information one at a time but very fast.

Hope you have a better idea.

Thanks for your help.

Hello,

Sorry, you can’t make vvvv run any faster than, I don’t know 120 frames/sec, so that means only 2 updates per sec of your grid at best.

I am pretty sure the arduino has some code somehwere to convert the values it receives from the serial (a string) to a nicely filled array of 64 int elements.

Do you use firmata? (dunno what the current status is on that)

My idea would be to ask the Arduino people (they are almost as nice as the vvvv community ;) ) how you can convert a Serial.read() string that is 64 integers (0 or 1) to something you can feed your LED array with.

Without a code a can’t pinpoint and solve the problem, but I do understand it.

Good luck :)

edit: I found this on the Arduino Forums:

To convert a char to an int, subtract ‘0’ from the char:
int S = SlotNo - ‘0’;

edit2: Send me a PM so we can talk on Skype/MSN about this, I just got my Arduino Mini, and I can use all the help I can get. (building a 1 channel MIDI device, nothing to do with vvvv)

Hi,

maybe this could help us : http://www.arduino.cc/en/Tutorial/TextString

I haven’t already try this but I will do really soon.

Thanks again for your help west (and Kalle :p ) I will keep you inform.

hmm I have arduino<->vvvv communication reading 137 hardware switches (plus some pots) and sending on/off state to the same amount of LED:s using my own serial protocol.

It was a while since I wrote it but I think I encode one 8xLED row as two characters in a string, and then all rows are appended into one string that is sent in one go with the RS232 node. So half a row, 4-LED:s = 4bits = 16 combinations means that each character in the string can be one of 16 symbols, for that I use the series of 16 chars in the ascii chracter table starting from ‘0’ to ‘?’ since at least 0-9 is easily human readable and having them in series makes the arduino code easier.

Arduino code and vvvv patch for 128 red + 9 green LEDs: (colors are of course not important other than that they’re mentioned in the code)

void serialRecieve()
{
  int incoming = 0;

  byte serialBuffer = Serial.available();
  if (serialBuffer >= 36 )
  {
    incoming = Serial.read();
    byte msg[35](35);
    byte index = 0;
    while( (incoming != 'X') && (Serial.available() > 0) )
    {
      msg[index](index) = (byte) incoming;
      incoming = Serial.read();
      index++;
    }
    
    if(index == 35)
    {
      for(int i = 0; i < 16; i++)
      {
        leds[i](i) = (msg[i*2](i*2) - '0') ;
        leds[= (msg[i*2 + 1](i](= (msg[i*2 + 1](i) ) - '0')  << 4 ;
      }
      greenLeds[0](0) = (msg[32](32) - '0') ;
      greenLeds[= (msg[33](0](= (msg[33](0) ) - '0')  << 4;
      greenLeds[1](1) = (msg[34](34) - '0') ;
    }
  }
}

Note that it would probably be much smarter to only send values that have changed instead of this brute force method.

mastercontrolbox (Device).v4p (47.5 kB)