Revisited yesterday’s code after some help from @Big_Pause and fixed up the problems I was having. Turns out the issue with delimiting values in Max was a confusion with the [select] and ASCII commands. All sorted now, allowing me some nice simple control. The below patch create a simple Boom-Blap drum machine. Two buttons trigger samples; two potentiometers adjust the samples’ pitch; and a piezo transducer controls the feedback level of a delay effect:
Arduino code:
int potPin1 = 0;
int potPin2 = 1;
int buttonPin1 = 2;
int buttonPin2 = 3;
int piezoPin = 4;
int potVal1 = 0;
int potVal2 = 0;
int button1 = 0;
int button2 = 0;
int piezo = 0;
int THRESHOLD = 100;
void setup() {
pinMode(potPin1, INPUT);
pinMode(potPin2, INPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(piezoPin, INPUT);
Serial.begin(9600);
}
void loop() {
potVal1 = analogRead(potPin1);
potVal2 = analogRead(potPin2);
button1 = digitalRead(buttonPin1);
button2 = digitalRead(buttonPin2);
piezo = analogRead(tempPin);
Serial.print(potVal1/4, BYTE);
Serial.print(" ");
Serial.print(potVal2/4, BYTE);
Serial.print(" ");
Serial.print(button1, BYTE);
Serial.print(" ");
Serial.print(button2, BYTE);
Serial.print(" ");
Serial.print(piezo/4, BYTE);
Serial.println();
delay(100);
}
All lots o’ fun.
Should take this point to also thank Joshua Noble, the author of this incredible book I’ve been using to learn all this stuff… Joshua is a brilliant dude and went out of his way to help me on a couple of little issues I stumbled across (being too thick to solve them myself). If you’re interested in any of the things I’m looking at in this #CreativePact – the chances are it’s in his book – so go buy it!










…even if it does resemble a “pickled foetus”.




