GPIO for pd2dsy

Hi, I am using the daisy pod with pure data, but i would like to use also extra sensors (flex and sonar). How do I read the analogue and digital pins in pd2daisy? I could not find any conversation about this. Example: I have a variable resistor connected to analogue 1 of the pod and I would like to read it inside pure data (same as a knob) what hv_param object can i use for it? or any other way?
Thanks a lot.

Hello!

We can think of Daisy Pod as Daisy Seed but connected to a breakout board with knobs, encoder, LED, audio jacks, and etc.

In order to do custom hardware configuration, you need to use a custom json file, which needs to be created & saved in the same folder as the patcher that you’re flashing into your Daisy. I usually just make it in TextEdit and save it as .json. Make sure you’re using plain text and not rich text.

Daisy Pod, which you may have noticed, only has two available ADCs as the other ones are already utilized. So, the available ones are ADC 1 (pin 16 in the JSON file) and ADC 9 (pin 24 in the JSON file).

You can see which pin is which here.

So for testing, you can set up a Pure Data file called “project.pd” and a “customseed.json” file and save them both in the same pd2dsy folder. Then run this in the terminal.

python pd2dsy.py -c customseed.json project.pd

customseed.json will look like this. Notice how your Flex sensor is mapped to pin 16 and Sonar sensor is mapped to pin 24?

{
	"name": "customseed",
	"som": "seed",
	"components": {
		"knob2": {
			"component": "AnalogControl",
			"pin": 15
		},
		"flex": {
			"component": "AnalogControl",
			"pin": 16
		},
		"knob1": {
			"component": "AnalogControl",
			"pin": 21
		},
		"sonar": {
			"component": "AnalogControl",
			"pin": 24
		},
		"sw1": {
			"component": "Switch",
			"pin": 27
		},
		"sw2": {
			"component": "Switch",
			"pin": 28
		},
		"encoder": {
			"component": "Encoder",
			"pin": {"a":26, "b":25, "click":13 }
		},
		"led1": {
			"component": "RgbLed",
			"pin": {"r":20, "g":19, "b":18 }
		},
		"led2": {
			"component": "RgbLed",
			"pin": {"r":17, "g":24, "b":23 }
		}
	},
	"aliases": {
		"switch": "sw1",
		"button": "sw1",
		"switch1": "sw1",
		"button1": "sw1",
		"switch2": "sw2",
		"button2": "sw2",
		"enp": "encoder_press",
		"switch3": "encoder_press",
		"press": "encoder_press",
		"knob": "knob1",
		"ctrl": "knob1",
		"ctrl1": "knob1",
		"ctrl2": "knob2",
		"led": "led1"
	}
}

And in your Pure Data patcher, you’ll need a receive object that says “r flex @hv_param” to get the Flex sensor data.

Apologies in advance if this .json file does not work. It’s more for giving you an idea of what it will look like. It should work though but do let me know if I did overlook anything.

Let me know if you have any further questions!!

4 Likes

Wow I just a few minutes ago was reading your youtube comment to me about json files. Here is the info I needed (I think) about how the Daisy Pod is mapped, pots and switches wise.

1 Like

How do you have control over each color in this RgbLed in pure data?
Thank you

1 Like

Please watch this section of the video (the link is timestamped): https://youtu.be/KTM8pHN3_mM?si=BuvmW49SkH8o5S2P&t=530

So what’s happening is that the RGB led has one pin per color (so the led has red pin, green pin, and blue pin). And the Seed is sending PWM output individually. So pin D20 is connected to the red pin, pin D19 is green, and pin D18 is blue for one of the RGB led on the Pod.

Referencing how the leds are connected to the Pod is helpful: https://github.com/electro-smith/Hardware/blob/master/reference/daisy_pod/ES_Daisy_Pod_Rev3.pdf

2 Likes