
The '121s are across some male header. That shouldn't short anything that shouldn't be, right? Then i've jumped the address pins of two of them to what should be the right points to make them enumerate right. All the soldering looks good to me, i don't think the hardware's bad.
I threw this code together but the thing just whines. I don't think i'm crazy with the timing, i think it should be audible if it's recognizing input. Maybe the '121s draw too much power, i didn't check that.
#include <Wire.h>
#include "Adafruit_MPR121.h"
const uint8_t freq1 = 300;
const uint8_t freq2 = 400;
const uint8_t freq3 = 500;
const uint8_t numberoffrets = 12;
unsigned long t;
unsigned long oldmicros;
int string1[freq1];
int string2[freq2];
int string3[freq3];
uint8_t c;
Adafruit_MPR121 cap1 = Adafruit_MPR121();
Adafruit_MPR121 cap2 = Adafruit_MPR121();
Adafruit_MPR121 cap3 = Adafruit_MPR121();
void setup() {
delay(100);
pinMode(1, OUTPUT);
Wire.begin();
if (!cap1.begin(0x5a)) while(1);
if (!cap2.begin(0x5b)) while(1);
if (!cap3.begin(0x5c)) while(1);
//cap2.begin(0x5b);
//cap3.begin(0x5c);
//wire.begin(0x5A);
//wire.begin(0x5B);
//wire.begin(0x5C);
}
void loop() {
t = micros();
if (t > oldmicros+1000) {
for (uint8_t fret=1; fret < numberoffrets; fret++){
if (cap1.touched() & (1 << fret)) {for(uint8_t c=1; c < freq1/2; c++){string1[c] = (random(2^16)-2^8);}}
if (cap2.touched() & (1 << fret)) {for(uint8_t c=1; c < freq2/2; c++){string2[c] = (random(2^16)-2^8);}}
if (cap3.touched() & (1 << fret)) {for(uint8_t c=1; c < freq3/2; c++){string3[c] = (random(2^16)-2^8);}}
oldmicros=0;}
for(uint8_t c=1; c<freq1; c++){string1[1] = (string1[2]+string1[3])/2);}
for(uint8_t c=1; c<freq2; c++){string2[1] = (string2[2]+string2[3])/2);}
for(uint8_t c=1; c<freq3; c++){string3[1] = (string3[2]+string3[3])/2);}
analogWrite(1, string1[1]+string2[1]+string3[1] / 3);
}
It should be an implementation of the Karplus-Strong algorithm but i'm staring at the void. Next step is serial feedback or the funner parts of hardware.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.