My process for designing this project began with the hardware. Arguably the most fun part, I started with a breadboard, as pictured below.
After some experimenting and iterating, I finally got to the finished circuit, shown in the breadboard and circuit diagram below.
Next up, I had to do some CAD, which is not as easy as it looks (it doesn't look easy, either).
I started with a sketch, pictured below.
After the sketch and a lot of finessing, I ended up with something completely usable (and printable!).
Next up is the code. It's actually extremely simple, thanks to the components I used (primarily the Sparkfun MicroView and the Electret Microphones) being very compatible.
Here's the code:
//code by v @ violetcastles.com
#include <MicroView.h>
int lmic = A1;
int rmic = A2;
const int sampleTime = 50;
uint8_t ambient [] = {
0xBF, 0xFF, 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xFF, 0xFE,
0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x38, 0x08, 0x38, 0x60, 0x00, 0x00,
0x00, 0xC0, 0x60, 0x40, 0x40, 0x40, 0x80, 0x60, 0x60, 0x40, 0x80, 0x00, 0xBC, 0xFC, 0x20, 0x20,
0x60, 0xE0, 0xC0, 0x00, 0xE8, 0xA8, 0x00, 0xC0, 0x60, 0x20, 0x20, 0x20, 0xC0, 0x00, 0x80, 0x40,
0x40, 0x60, 0xE0, 0xC0, 0x00, 0x60, 0xE0, 0xF0, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xF5,
0xFF, 0xEB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x06, 0x00, 0x02, 0x00, 0x06, 0x07, 0x0C,
0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x06, 0x0F, 0x00, 0x07, 0x0F, 0x0C, 0x08,
0x08, 0x0F, 0x07, 0x00, 0x0F, 0x0F, 0x00, 0x05, 0x0F, 0x05, 0x09, 0x09, 0x09, 0x00, 0x0E, 0x0F,
0x00, 0x00, 0x0B, 0x0F, 0x00, 0x00, 0x05, 0x0B, 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xFB, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0xFD, 0xFF, 0xC0, 0xC0, 0xC0, 0xC0, 0x40, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
0xC0, 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0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF0, 0xB8, 0x1C, 0x04, 0x00, 0x0C, 0x1C, 0xA8, 0xF0, 0x00, 0xA0, 0xE0, 0x00, 0x00, 0xE0, 0xE0,
0x00, 0x00, 0x48, 0xE8, 0x00, 0xC0, 0x20, 0x20, 0x20, 0xC0, 0xC0, 0x00, 0x60, 0x60, 0xD0, 0xF0,
0x60, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x0F, 0x0A, 0x04, 0x08, 0x1C, 0x1E, 0x2F, 0x22, 0x20, 0x07, 0x03, 0x0C, 0x0C, 0x0A, 0x05,
0x00, 0x00, 0x0F, 0x0F, 0x00, 0x06, 0x0D, 0x0D, 0x09, 0x09, 0x01, 0x00, 0x00, 0x00, 0x0D, 0x0F,
0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xDF, 0xAF, 0xCD, 0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0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
0xA0, 0x60, 0xE0, 0x60, 0xE0, 0xDF, 0xFE, 0xF5, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
void setup() {
Serial.begin(9600);
uView.begin();
uView.clear(PAGE);
uView.display();
}
void loop() {
MicFunction();
}
void MicFunction(){
uView.clear(PAGE);
unsigned long startTime= millis();
unsigned int PTPAmp = 0;
int micTotal = analogRead(lmic) + analogRead(rmic);
while(millis() - startTime < sampleTime)
{
if( micTotal < 2050) //prevent erroneous readings
{
if(micTotal >= 500){
uView.drawBitmap(ambient);
delay(50);
}
if(micTotal >= 700){
uView.drawBitmap(quiet);
delay(100);
}
if(micTotal >= 850){
uView.drawBitmap(loud);
delay(1000);
}
}
}
uView.display();
}
Those three chunks of color values are the bitmap images displayed on the screen, depending on the level of sound in the environment.
Making the bitmaps was relatively straightforward, all I had to do was create an image with the same amount of pixels as the MicroView display.
Next up, soldering. Here's some pictures of my process.
And that's it! Here's the final prototype.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.