SuperCollider getting Arduino Data
SerialPort.listDevices; // List available ports
p = SerialPort.new("/dev/ttyACM0", 9600);
// Read incoming data
r = Routine({
var byte;
loop {
byte = p.read;
// Map byte to frequency (example)
{SinOsc.ar(byte * 10)}.play;
0.01.wait;
}
}).play;
Arduino code for SuperCollider
Same as for web audio api
const int sensorPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(sensorPin);
Serial.write(map(sensorValue, 0, 1023, 0, 255));
delay(10);
}