Hardware button in vvvv via arduino

Hi,

I am a new vvvv user and also a new arduino user :). For my final project I made a simple button which is activated when you step on it. I imported the data into vvvv patch to change the position of a quad. RS232 node output gives “0” when the button is not activated and, gives “1” when it is activated. however I could not connect that data to my switch node. Could you please help me how to solve this? Here is my arduino code:

int val = 0; // Variable to hold switch value. Initially 0

void setup()
{
Serial.begin(9600); // Open serial channel of 9600 baud rate
pinMode(12,INPUT); // Set 12th digital pin as input

}

void loop()
{
val = digitalRead(12); // Read digital pin 12 and set it to val
Serial.write(val); // Send the value of val through selected COM
Serial.println(val); // To check from Serial Monitor)

}

and here is a screenshot from my patch:

thanks a lot

you dont need to .write val. write is for PWM and IO Output from arduino.
you just need to do println wich is printing on serial port

the missing node is AsValue(string)

thanks, I have already used it, but it didn’t work. I connected the string output pin to the input pin of asvalue (string) node and the output pin of the asvalue to the toggle. however it didn’t react the toggle.

try print this :
Serial.print(val, DEC);
Serial.println("|");

and copy this code and paste in your patch and connect it to the rs232 output:

waow, thanks a lot!, but I didn’t understand where to paste that code in the patch. As I said I am a new vvvv user, and I’m in beginner level in coding (:

Asvalue > getslice should normally work.
Are you with the spread rs232 node or the basic one?
Prefer basic one.

hi,
Now, I connected the asvalue node to the getslice input pin, and getslice to the toggle, but it didn’t work. Here is the screenshot (because I don’t know what is the basic one). And also I uploaded my patch.

could you please check my patch, because I couldn’t find my mistake :(. thank you very much for your help.

mapping43.v4p (70.7 kB)

hum…

so when you press your button you have 1 0 printed in output ? and getslice pos 0 doesn t do anything ? is that right ?
if yes: connect a change to the the IO output, to the s+h right pin. Connect the IO output to the s+h input and make your getslice from the output of s+h

if no: you have something like 0 1 0 getslice should be set to index 1

hope this help…

@sedefaydogan just paste it anywhere in your patch and connect the rs232 output to it, the output of this structure will be the clear string to be converted with one asvalue.
i use this piece of patch to receive multiple values and separate them back.
it should work also to clean the rs232output for just one value…
…btw do you see 1 in the rs232 output when your button is pressed?

@karistauf Thank you so much, I think I solved the problem. I think because of the sustained incoming data I could not convert the string to the value. When I put delay for the incoming data in arduino software it is now stable. However, unfortunately it reacts a bit slowly because of the delay, but it is not a big deal. I also tried your nice solution too, but I think I could not manage it :/, thank you sooo much for your help :)

@sapo thank you sooo much for that structure. I tried it, but I must have done something wrong, the output string is still not clear. I see 1 in the rs232 output when I pressed the button. For now, I overcome the situation by giving delay for the incoming data in the arduino software, because I have so little time to prepare for my jury :). After the jury, I want to develop my first vvvv project :) and use your structure in a proper way.

@sedefaydogan indeed you must also use
Serial.print(val, DEC);
Serial.println("|");
in your arduino code to get my structure working. you did that?

aaa, yes! sorry about that, I forgot to edit the arduino code. It works perfectly. Thanks a lot!

just a little note/tip/trick on the subject of buttons… I have found it cheaper when I only need push buttons to mod a computer keyboard instead of using an arduino board. I love arduino, but use it to interface with sensor data rather than just a switch cause there are a bunch of cheaper/easier/faster ways to get switch data (think MAME controller…)

@sedefe: yes it works only with ethernet shield. I will release soon artnet sender also