• cfry

    Pendulum Coils (2019)

    Installation/sound work exhibited 2019

    Synthesis and Arduino handling in Pd

    posted in output~ read more
  • cfry

    @alexandros how do you use this? For i/o audio, (as an audio interface?) or very high resolution analog control values?

    posted in I/O hardware diyread more
  • cfry

    Hi,

    is there an abstraction for real time recording of control data? As of now I convert control data to midi and record it externally (Reaper). I'd prefer to do it in Pd. I want to be able to replay a performance but do not need to align it to a time signature or any other "midi" features.

    I imagine I could built it with [textfile] and [qlist] as shown here:

    http://www.pd-tutorial.com/english/ch04s02.html

    cheers!

    posted in technical issues read more
  • cfry

    What type of arduino do you use with Pd, and why? Just curious.

    posted in I/O hardware diyread more
  • cfry

    @alexandros thanks, it all works!

    I merged the codes for in and outs and also changed so you can set up all of the pins with arrays (as you did in the latter code). Then you can set up the pins in any order.

    Here is the Arduino code. Do you spot any errors I may have introduced?

    //number of elements in array need to match for() cycles
    int pinsIn[4] = {2, 7, 10, 11};
    int pinsAnalog[3] = {0, 2, 3};
    
    int pin = 0;
    int val = 0;
    // some random pins
    int pinsOut[4] = {3, 4, 5, 6};
    
    void setup()
    {
      //set up a total of pins for input (has to match number of elements in array)
      for(int i = 0; i < 4; i++)
      pinMode(pinsIn[i], INPUT);
      
      for (int i = 0; i < 4; i++) {
        pinMode(pinsOut[i], OUTPUT);
        digitalWrite(pinsOut[i], LOW);
      }
      
      Serial.begin(115200); // perhaps use a faster baud rate
    }
    
    void loop()
    {
      Serial.print("knobs"); // use "knobs" as a keyword so you can receive
      // the knob values as a list with a [r knobs] in Pd
      for(int i = 0; i < 3; i++){
        unsigned int knob = analogRead (pinsAnalog[i]);
        Serial.print(" "); // first print a white space to separate the "knob" keyword from the values
        // and the values from each other
        Serial.print(knob); // then  print the actual knob value
      }
      Serial.println(); // finally print a newline character to denote end of data for keyword "knobs"
    
      // the same technique applies to the switches too
      // receive the switch values as a list with [r switches]
      Serial.print("switches");
      for(int i = 0; i < 4; i++) {
        int switchVal = digitalRead(pinsIn[i]);
        Serial.print(" ");
        Serial.print(switchVal);
      }
      Serial.println();
      
      //handle digital outputs
      if (Serial.available()) {
        static int temp;
        byte in = Serial.read();
        if (isDigit(in)) {
          temp = temp * 10 + in - '0';
        }
        else if (in == 'p') {
          pin = temp;
          temp = 0;
        }
        else if (in == 'v')  {
          val = temp;
          temp = 0;
          digitalWrite(pinsOut[pin], val);
        }
    }
    }
    

    In Pd I was not able to use [r switches] or [r knobs] but had to use [route]. Is this the correct way to use [serial_print]?
    Skärmavbild 2021-01-04 kl. 01.11.18.png

    And here it is on the breadboard:
    20210104_010936.jpg

    posted in I/O hardware diyread more
  • cfry

    @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.

    posted in I/O hardware diyread more
  • cfry

    @oid thanks for that pretty example patch. It made me really understand the whole concept and flow.

    posted in I/O hardware diyread more
  • cfry

    @alexandros could you give an arduino code example on how to use digital in and out at the same time?

    posted in I/O hardware diyread more
  • cfry

    @oid said:
    ...This looks like a pretty good write up on the switch matrix, only skimmed it but all the important bits seem to be there. https://learn.sparkfun.com/tutorials/button-pad-hookup-guide/background

    I have completed @alexandros Arduino for Pd'ers now (except servo and multiplexing since I do not have the components needed). I feel it will be easier now when I do not have rely on Pduino. Although there are some parts I do not have full control of (read: hexadecimal handling) I think I can manage with some copy and paste-ing.

    So now I need to set up a switch matrix a la midi keyboard. But the tutorial above is hard to adapt to my scenario. I have looked around but I can not find a guide that is more spot on. Any ideas?

    I got the diodes but I need to understand how to make and connect the circuit to the arduino, make the arduino code, and then merge this code with the code for communication with Pd (the latter code is ready to go).

    Thanks a lot folks :)

    posted in I/O hardware diyread more
  • cfry

    @alexandros this is a bit OT but where can I find info on the zexy lib?

    posted in I/O hardware diyread more

Internal error.

Oops! Looks like something went wrong!