Arduino > Rotary Encoder (Drehimpulsgeber) > Video Speed

Hello, via the serialport RS232 I can read my rotary encoder. I want to use the encoder or the values from it to control the playback speed of a video. Unfortunately I’m a newbie and can’t get it to work yet.

I can see the values of the rotary encoder in vvvv, but I don’t know what to do now:

And here´s my video playback so far:

Please have a look at the “Receiving Data” part of this example:


It should get you starting. And finally you’ll need a Map (Value) Node to convert the range of your incoming value (i’m assuming 0…255) to the range of the Speed input (something like 0…2).

Also, if you’re completely new to vvvv consider starting with the newer version: vvvv gamma for a more modern approach.

My range is from 0…endless, because I have a infinite RotaryEncoder that counts endless. I don´t know how to range this with a Map Node.

My second problem: With Filestream Node and IOBox (with Slider) I cannot control the film speed properly. I need it as follows:
When I turn the Rotary Encoder, the movie should play at the speed that the Rotary Encoder is turned. When I stop turning, the film should stop. The speed of the Rotary Encoder and the speed of the film should be directly coupled.

At the moment it is so, that the film stops as long as I turn the Rotary Encoder. When I then let go, the film plays at the new speed. How can I change it as described above?

ok, so we’re not talking about “Speed” then, but “Postion”. for this case you’ll need to use the Player (EX9.Texture) node instead of the Filestream, because it will let you access individual frames. see its helppatch. also note the node takes a sequence of images rather than a movie.

since we’re not talking speed, but direct access of individual frames, maybe you won’t need the map node at all.

ok, with player I can load JPGs. But I don´t know how to connect from “Received Data” to “Position”. Position Pin is where you can read 39.7848

note there are two Player nodes. use the one that does not have “Timebased” in its version because you want to control it by directly specifying the frame to view. “Preload Frames” is the (oddly named) input that you’ll have to connect to.

and what exact Rs232 node are you using there? it doesn’t seem to be the default one shipping with vvvv. did you build that one? what are the numbers it returns?

Now I´m using the default RS232 node (before it was a node from a patch I found in one of the contributions on the vvvv site). The numbers of the previous RS232 node provided ascending numbers when turned clockwise. When turned anticlockwise, the previous RS232 node provided descending numbers down to the minus range.
The default RS232 node used now provides something different, see below in the screenshot.

I also changed the player node now (to the one without “Timebased”). Unfortunately, I don’t know how to connect the output of the serial node to the player.


Now I have added “AsValue” to the Serial node. The output delivers strongly fluctuating numbers up to approx. 50. If I now connect the output of this to the player pin “Preload Frames” and turn the rotary encoder, a video image appears. Unfortunately, it is not as it should be. Only one frame is displayed and it flickers.

ok, so what you see coming out of the RS232 node is the data your device sends. now you need to know what protocol this data is sent in, in order to be able to receive it properly.

from what it looks like it may be 32bit integers separated by \r\n or carriage-return+linefeed (0D 0A in the screenshot). if this assumption is correct, your patch could look like this:


Now it works! Great. Last problem: Frames are too fast. How can I slow down? Perhaps by reducing the output number from Tokenizer node?

heh, i’m afraid the patch you built doesn’t make much sense. it apparently does something but you’ll soon notice that it doesn’t do what you want it to do.

follow my example screenshot. if that doesn’t work you’ll have to find out more about the protocol of the data you receive.

I followed your example screenshot, but it doesn´t work. When I turn the Rotary Encoder, the video plays at too high a speed. Even when I stop turning, the video still plays at too high a speed. The values on the output go crazy on their own.

well, then, as i said, i only made a guess regarding the protocol from your screenshot. the guess was wrong. i’m afraid we’ll not be able to help you further without you finding out more about the protocol in use here.

if this is an arduino code sending the data, you could upload the code here so we can have a look.

I totally understand and thanks for the help! I connected the Arduino as you can see here:

Here is the Arduino code:

volatile long temp, counter = 0; //This variable will increase or decrease depending on the rotation of encoder

void setup() {
Serial.begin (9600);

pinMode(2, INPUT_PULLUP); // internal pullup input pin 2

pinMode(3, INPUT_PULLUP); // internalเป็น pullup input pin 3
//Setting up interrupt
//A rising pulse from encodenren activated ai0(). AttachInterrupt 0 is DigitalPin nr 2 on moust Arduino.
attachInterrupt(0, ai0, RISING);

//B rising pulse from encodenren activated ai1(). AttachInterrupt 1 is DigitalPin nr 3 on moust Arduino.
attachInterrupt(1, ai1, RISING);

void loop() {
// Send the value of counter
if( counter != temp ){
Serial.println (counter);
temp = counter;

void ai0() {
// ai0 is activated if DigitalPin nr 2 is going from LOW to HIGH
// Check pin 3 to determine the direction
if(digitalRead(3)==LOW) {

void ai1() {
// ai0 is activated if DigitalPin nr 3 is going from LOW to HIGH
// Check with pin 2 to determine the direction
if(digitalRead(2)==LOW) {

ok, here is the important line:

Serial.println (counter); 

this tells us that the value is simply sent as string with \r\n at the end. in this case the patch should work like this:


It works. But the playback behavior of the player is not as intended: The playback speed always remains the same, no matter if I turn the Rotary Encoder fast or very slow.
How can I link the playback speed to the rotation speed of the rotary encoder? I tried it with a MapRange node, but it doesn’t work well yet:

Try this:
Currently there is the Enqueue node used to make sure you’re not missing any of the incoming data. in case too much data is coming in in one frame, it is queued and then one value is returned after the other, frame by frame. maybe this is not what you want. instead you could replace it with a CDR node and always only take the last value that was received in this frame. this should already give you a more immediate feedback.

With the CDR (RAW) node the patch hangs/crashes…

What kind of frames are recommended here? jpg, tif or something else?