EDIT: this pinout diagram contradicts the one found in the IDE and the labels on the board, but verifies what I observed.

Also, the weird behavior with the synth seems to be caused by me manually controlling the build in LED (with DigitalOut(12)) of a toggle switch (DigitalIn(8)) that also automatically turns it on when the switch is turned on. I guess in some circumstances it ends up creating a feedback loop/race condition and producing strange results.


I'm attempting to drive LEDs from digital pins 10, 11, and 12 on a bela mini (pocketbeagle rev. A2, bela mini rev. B4) through the multichannel expander cape (rev. A2) using supercollider, and after pulling a lot of hair out, I found that:
- the pin labeled D11 doesn't seem to do anything
- the pin labeled D10 is connected to DigitalOut(11)
- the pin between what is labeled D10 and 3.3V is connected to DigitalOut(10)
- the pin labeled D12 is connected to DigitalOut(12), as expected

I verified this using SuperCollider > 1-digital-out and Digital > digital-output.

Initially when using my own sketch (see below) to test the interface I'm building, I also noticed that attempting to send to DigitalOut(10) often caused unpredictable behavior (e.g. stuck synths, distorted sound).

I haven't dug too deep into exactly what's going on, and in the interest of time will just avoid DigialOut(10) for now, but I'm curious, has anyone else come across this behavior before? Is there some kind of easy fix I can apply to take care of it? thanks!

/*******************
WTF?!:
- digital out 12 is ok, but 11 goes to pin 10?! (and 10 goes to the pin b/w 10 and 3.3v?!)
--> using pin 10 also seems to cause some very strange behavior at times (e.g. triggering multiple synths to play)

Blink a LED using a Tactile Switch
Connect a LED+resistor to digital pin 0
Connect a tactile switch+pull-down resistor to digital pin 1

DigitalOut takes three arguments:
ar (digitalPin: 0, output: 0, writeMode: 0, mul: 1, add: 0)

digitalPin:  Digital pin number to write to. Pin numbers begin at 0. This value cannot be modulated.
Pin numbers are labled in the Pin Diagram tab in the Bela IDE.

output:  Value to write out to the pin - the value will be 1 when the argument is larger than 0, otherwise 0.

writeMode:	Mode of writing to the output, this can be 0 (only when value changes) or 1 (continuously, at audio rate). This value cannot be modulated.

DigitalIn takes one argument:
ar (digitalPin: 0, mul: 1, add: 0)

digitalPin: Digital pin number to read. Pin numbers begin at 0. This value cannot be modulated.

(c) 2017: Jonathan Reus, Marije Baalman, Giulio Moro, Andrew McPherson
*/

s = Server.default;

s.options.numAnalogInChannels = 2;
s.options.numAnalogOutChannels = 2;
s.options.numDigitalChannels = 16;
s.options.maxLogins = 4;  	   // set max number of clients
s.options.bindAddress = "0.0.0.0"; // allow anyone on the network connect to this server

s.options.blockSize = 16;
s.options.numInputBusChannels = 2;
s.options.numOutputBusChannels = 2;

s.waitForBoot{
	SynthDef('buttonControl', {arg inPin, outPin, freq = 220;
		// read the value at the pin
		var button = DigitalIn.ar(inPin);
		var gain = AnalogIn.ar(1); // returns a value from 0-1
		var pan = AnalogIn.ar(0).range( -1, 1 );
		var sig = SinOsc.ar(freq, 0, ((gain * 0.15) + 0.05) * button);
		// toggle an LED on outPin
		DigitalOut.ar(outPin, button);
		// gate a sinewave
		// Out.ar(0, sig);
		Out.ar(0, Pan2.ar(sig,pan));
		// Out.ar(0, SinOsc.ar(freq, 0, ((gain * 0.15) + 0.05) * button));
		// Out.ar(0, Pan2.ar(SinOsc.ar(freq, 0, ((gain * 0.15) + 0.05) * button)), 1);
	}).add;	
	
	s.sync;
	
	// a = Synth('buttonControl', ['inPin', 3, 'outPin', 11]);
	// to do replace this w/ iteration...
	a = Synth('buttonControl', ['inPin', 0, 'outPin', 11, \freq, 60.midicps]); // setting outPin to 10 causes weird behavior
	b = Synth('buttonControl', ['inPin', 1, 'outPin', 11, \freq, 61.midicps]);
	c = Synth('buttonControl', ['inPin', 2, 'outPin', 11, \freq, 62.midicps]);
	d = Synth('buttonControl', ['inPin', 3, 'outPin', 11, \freq, 63.midicps]);
	e = Synth('buttonControl', ['inPin', 4, 'outPin', 11, \freq, 64.midicps]);
	f = Synth('buttonControl', ['inPin', 5, 'outPin', 11, \freq, 65.midicps]);
	g = Synth('buttonControl', ['inPin', 6, 'outPin', 11, \freq, 66.midicps]);
	h = Synth('buttonControl', ['inPin', 7, 'outPin', 11, \freq, 67.midicps]);
	i = Synth('buttonControl', ['inPin', 8, 'outPin', 11, \freq, 68.midicps]);
	i = Synth('buttonControl', ['inPin', 9, 'outPin', 11, \freq, 69.midicps]);
};

ServerQuit.add({ 0.exit }); // quit if the button is pressed
8 days later

Thanks for raising this, it turns out that there is indeed an issue with the silkscreen of the Bela Mini Multichannel Expander Rev A2 whereas the silkscreen for the D10 and D11 pins is off by 1. We now fixed this in the IDE diagram and will fix it in the next hardware release. Updated diagram can be found, e.g.: here , or on your board by updating to the latest master branch.

I am not sure I understand from the above edit whether you have any other outstanding issues with Supercollider and digital I/O, let me know if that's the case.

    7 months later

    giuliomoro oops, i missed this way back when, but thanks for your reply and updating the diagram.

    regarding strange i/o behavior, if i remember correctly it was a result of trying to control the led on the switch i was using in a way it wasn't designed to be used.