WEEK 9 | INPUT DEVICES



Sound Board

I wanted to make a sound board, because it can be useful for my final prject - which is the dancing laces.
I downloaded the traces of the digital hello.mic.45 from the website and milled it. The modela didn't work
weel from some reason for some people, so I used the other one (SRM). I milled it and it turned out to be fine
but than I left for few minutes and when I was back to cut the outline, someone already removed my board, so I didnt cut
the outline. I promise to use the other part of the copper for my next board!

Now was the soldering part. I don't know why, but the digital mic was in the drawer says analog mic,
so it either the link was leading to the analog mic, or the mic was in the wrong drawer...
I soldered everything really easily - I feel like a pro now and I enjoy it - but I couldn't find
one of the parts that i thought was a regulator but it was opamp. I couldn't find it and opened an issue,
so I got an answer in some point but the schedule was already too tight - I hope I will have the time to
actually program the board and read it!

OK! I had some time so solder the missing piece this morning, between
thesis class and TAing - time is a valuable thing.
soldering didn't take long, but programming didn't work as easy as I expected (or at all)!
I used some other people instructions, and programming the serial software thing (I'm not
totaly sure why do I need it) - but it said the sketch was too big and I couldn't get any resault.
now I'm thinking maybe I needed to change to volume initial number?!
Anyway, I don't have more time to try now, because I don't want to push things on the
site in the last minute. This is the code I tried:

#include SoftwareSerial.h

#define rxPin 7
#define txPin 2

// set up a new serial port
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);

void setup() {
// define pin modes for tx, rx:
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
}


int val = 0;

const int THRESHOLD = 512;

const int middleValue = 256;

const int numberOfSamples = 64;
int sample;
long signal;
long averageReading;

long runningAverage = 0;
const int averagedOver = 16;



void loop()
{
val = analogRead(rxPin);
if(valTHRESHOLD)
{ // read the input pin
long sumOfSquares = 0;
for(inti=0;inumberOfSamples;i++) {
sample = val; // take a sample...reminder: val = analogRead
signal = (sample - middleValue); // work out its offset from center, 1024 is the max. analog value, 512 is half of that.
signal *= signal; // square number to make all values postive
sumOfSquares += signal; // add to the total
}
averageReading = sumOfSquares/numberOfSamples; //calculate the running average
runningAverage = ((((averagedOver -1)*runningAverage)+averageReading)/averagedOver);


mySerial.println(runningAverage);

// delay 10 milliseconds before the next reading:

delay(10); // debug value
}

}