I'll copy here for everybody the discussion we had via e-mail
in Flash it can be a lot more complicated, but not impossible.
I didn't understand how pd handles the incoming data
how do you register an object in pd to a specific imput from Arduino?
how do you do something like this
val1 = analogRead(pin5)
val2 = digitalRead(pin6)
you wrote in the e-mail
To start read data from Arduino, you wait for the cycle marker byte: 255. Then you are at the top of the cycle. The next byte is digital pins 0-6, then digital pins 7-14. Then comes byte pairs for each analogIn, which are reassembled to make the 10-bit value. To send digital data to Arduino, its just a 3 byte cycle, 255 for the marker, one by for digital pins 0-6 and the next byte for pins 7-13.
I can understand if you serialize the data coming from Arduino
so that Arduino sends a long "string" or byte-cycle like
255 0 0 0 0 0 0 0 0 0 0 0 0 ?-? ?-? ?-? ?-? ?-?
- 255 is the starting cycle marker
- 6 bytes for digital pin 1->6
- 6 bytes for digital pin 7->14
- 5 pairs(?-?) what do they look like (I have to test it yet)
in this case is a bit easyer
there is only one object that listens to the incoming data and then dispatches the different information
to whoever is listening...or they simply pull the data from the dataset...
it could create some asyncronous computation but I'm not sure
I fear that it can be a mess to code for the user...but i'll give it a try
in the end of the day it would be great to code in Actionscript something like
// read analog value
val = Arduino.pin0.value
//set digital value
Arduino.pin6.value = HI;
in fact the pulsing could be handled internally by Flash with no problems and just sending single digitalWrites at the specified rate..that could be really cool...and doing FFT inside flash :o 8-)
What I fear is that the architecture would ask the user to code more or less the same things inside Flash that he would do in Arduino...I can see almost no point in that
it could be great if you could explain on the wiki a bit better the "string" that has to be SENT TO Arduino to set commands and the "string" that is RECEIVED FROM Arduino..
give some examples, it would make it easier.
I'll try it out