@alexandros
Here is the working Arduino code, (which is basically a straight copy from "project 8", but I wrote it while reading the tutorial)
// setup for 6 analog in och 12 digital in (pullup to be added).
//intended as experimental template. use pd patch
//made with tutorial Arduino for Pd'ers, project 8
byte myArray[25];
void setup()
{
for(int i = 2; i < 14; i++)
pinMode(i, INPUT);
Serial.begin(9600);
}
void loop()
{
myArray[0] = 0xc0;
int index = 1;
for(int i = 0; i < 6; i++){
unsigned int knob = analogRead (i);
myArray[index++] = knob & 0x007f;
myArray[index++] = knob >> 7;
}
for(int i = 2; i < 14; i++)
myArray[index++] = digitalRead(i);
Serial.write(myArray, 25);
}
Then I tried to incorporate project 1 (blink):
// set a variable to hold the ledddddddz pin number
int led = 13;
void setup()
{
// st pin 13 as output, to light up the LED
// whenever it is told so from Pd
pinMode(led, OUTPUT);
// start the serial communication o the Arduino
// and Pd can communicate with each other
Serial.begin(9600);
}
void loop()
{
while(Serial.available()){
byte ledState = Serial.read() - '0';
digitalWrite(led, ledState);
}
}
but when I tried to edit "blink" to work with several outputs and merge this in the project 8 code, I decided that I do not have enough understanding of the arduino code to pull it through. What is needed is, I think, another "for()" combined with digitalWrite() inside void loop()
Note: My plan now is to (still) use several Arduinos but with your code and abstractions (instead of the Pdunio). I will wait with the matrix switch setup since I have to take this in steps in order to have control of it.
This means that I am up and running, unless I want to use digital input and output from the same Arduino at the same time. I figure it would be great to have that sorted out beforehand so it works when I need it.
Thanks a lot.