This is my final project for EE47. I decided to make this project because it involved more design and electronics.
Music has an important role in human's life. It let us express our feelings, dance to it or motivate us. A world without sound would be very boring. We can hear music, we can even feel music, but how can we see music?
That´s why I wanted to design a way to see music, to see its rhythm and its beat. At the same time, I wanted another function, so I decided to make it also a lamp. I wanted to use the latest technology, so I decided to use bright color LED's for the musical function, as well as high power LEDs for the lamp.
The material which I decided to use is acrylic, which is laser-cuttable, as well as a light and clear material. I wanted it to be transparent, but at the same time that the interior could not be seen, so I sandblasted the acrylic to make it a frosty effect.
-
float factor = 0.8;
-
unsigned int limit = 0;
-
int sizeb = 250;
-
int pastValues [250];
-
int analogPin = A0; // read from multiplexer using analog input 0
-
int strobePin = 2; // strobe is attached to digital pin 2
-
int resetPin = 3; // reset is attached to digital pin 3
-
int ledPinBass = A9;
-
int ledPinMed = A7;
-
int ledPinHigh = A6;
-
int spectrumValue[7]; // to hold a2d values\
-
-
-
int point = 0;
-
-
-
void setup()
-
{
-
- // Serial.begin(115200);
-
-
pinMode(analogPin, INPUT);
-
pinMode(strobePin, OUTPUT);
-
pinMode(resetPin, OUTPUT);
-
pinMode(ledPinBass, OUTPUT);
-
pinMode(ledPinMed, OUTPUT);
-
pinMode(ledPinHigh, OUTPUT);
-
analogReference(DEFAULT);
-
-
-
digitalWrite(resetPin, LOW);
-
digitalWrite(strobePin, HIGH);
-
-
for (int z = 0; z<sizeb ; z++){
-
pastValues [z] = 300;
-
}
-
-
}
-
-
void loop()
-
{
-
digitalWrite(resetPin, HIGH);
-
digitalWrite(resetPin, LOW);
-
-
for (int i = 0; i < 7; i++)
-
{
-
digitalWrite(strobePin, LOW);
-
delayMicroseconds(30); // to allow the output to settle
-
spectrumValue[i] = analogRead(analogPin);
-
if (i == 0 ){
-
-
pastValues[point++] = spectrumValue[i];
-
// Serial.print(spectrumValue[i]);
-
// Serial.print ("L ");
-
if(point >sizeb)
-
point=0;
-
promedio();
-
-
//analogWrite(ledPin, (spectrumValue[i]/4) );
-
if (spectrumValue[i] >(limit)){
-
// digitalWrite(ledPin, HIGH);
-
// delay(25);
-
for (int y = 255;y>=0;y--){
-
analogWrite(ledPinBass,y);
-
delayMicroseconds(500);
-
}
-
}
-
else
-
analogWrite(ledPinBass, 0);
-
}
-
-
if (i == 4){
-
-
if (spectrumValue[1] > limit){
-
analogWrite(ledPinBass,255);
-
delay(5);
-
}
-
else{
-
analogWrite(ledPinBass,0);
-
}
-
-
// Serial.print( spectrumValue[2]);Serial.print( " " );
-
// Serial.print( spectrumValue[3]);Serial.print( " " );
-
// Serial.print( spectrumValue[4]);Serial.print( " " );
-
if (spectrumValue[2] > limit*factor*1.05 || spectrumValue[3]> limit*factor*1.05 ||spectrumValue[4]> limit*factor*1.05){
-
analogWrite(ledPinMed,255);
-
delay(5);
-
}
-
else{
-
analogWrite(ledPinMed,0);
-
}
-
-
-
}
-
-
if (i == 6){
- // Serial.print( spectrumValue[5]);Serial.print( " " );
- // Serial.print( spectrumValue[6]);Serial.println( " " );
-
-
if (spectrumValue[5] > limit*factor|| spectrumValue[6]> limit*factor ){
-
analogWrite(ledPinHigh,255);
-
delay(5);
-
}
-
else{
-
analogWrite(ledPinHigh,0);
-
}
-
-
-
}
-
/*
- // comment out/remove the serial stuff to go faster
- // - its just here for show
- if (spectrumValue[i] < 10)
- {
- Serial.print(" ");
- Serial.print(spectrumValue[i]);
- }
- else if (spectrumValue[i] < 100 )
- {
- Serial.print(" ");
- Serial.print(spectrumValue[i]);
- }
- else
- {
- Serial.print(" ");
- Serial.print(spectrumValue[i]);
- }
- */
-
-
digitalWrite(strobePin, HIGH);
-
}
-
-
}
-
-
void promedio (){
-
unsigned long suma = 0;
-
for (int z = 0; z <=sizeb;z++){
-
suma+=pastValues[z];
-
}
-
limit = suma/sizeb;
-
limit= limit*2.2;
-
// Serial.println(limit);
-
}
-
-
-
-
-
-
-
-
unsigned int limit = 0;
-
int pastValues [1000];
-
int analogPin = A0; // read from multiplexer using analog input 0
-
int strobePin = 2; // strobe is attached to digital pin 2
-
int resetPin = 3; // reset is attached to digital pin 3
-
int ledPin = A9;
-
int spectrumValue[7]; // to hold a2d values\
-
-
int point = 0;
-
-
-
void setup()
-
{
-
-
Serial.begin(115200);
-
-
pinMode(analogPin, INPUT);
-
pinMode(strobePin, OUTPUT);
-
pinMode(resetPin, OUTPUT);
-
pinMode(ledPin, OUTPUT);
-
analogReference(DEFAULT);
-
-
-
digitalWrite(resetPin, LOW);
-
digitalWrite(strobePin, HIGH);
-
-
for (int z = 0; z<1000 ; z++){
-
pastValues [z] = 300;
-
}
-
-
}
-
-
void loop()
-
{
-
digitalWrite(resetPin, HIGH);
-
digitalWrite(resetPin, LOW);
-
-
for (int i = 0; i < 7; i++)
-
{
-
digitalWrite(strobePin, LOW);
-
delayMicroseconds(30); // to allow the output to settle
-
spectrumValue[i] = analogRead(analogPin);
-
if (i == 0 ){
-
-
pastValues[point++] = spectrumValue[i];
- // Serial.print(spectrumValue[i]);
- // Serial.print ("L ");
-
if(point >1000)
-
point=0;
-
promedio();
-
-
//analogWrite(ledPin, (spectrumValue[i]/4) );
-
if (spectrumValue[i] >(limit)){
-
// digitalWrite(ledPin, HIGH);
-
// delay(25);
-
for (int y = 255;y>=0;y--){
-
analogWrite(ledPin,y);
-
delayMicroseconds(450);
-
}
-
}
-
else
-
analogWrite(ledPin, 0);
-
}
-
-
-
/*
- // comment out/remove the serial stuff to go faster
- // - its just here for show
- if (spectrumValue[i] < 10)
- {
- Serial.print(" ");
- Serial.print(spectrumValue[i]);
- }
- else if (spectrumValue[i] < 100 )
- {
- Serial.print(" ");
- Serial.print(spectrumValue[i]);
- }
- else
- {
- Serial.print(" ");
- Serial.print(spectrumValue[i]);
- }
- */
-
-
digitalWrite(strobePin, HIGH);
-
}
-
-
}
-
-
void promedio (){
-
unsigned long suma = 0;
-
for (int z = 0; z <=1000;z++){
-
suma+=pastValues[z];
-
}
-
limit = suma/1000.0;
-
limit= limit*2.5;
-
Serial.println(limit);
-
}
-
-
-
-
-
-
-
-
-
unsigned int limit = 0;
-
int pastValues [1000];
-
int analogPin = A0; // read from multiplexer using analog input 0
-
int strobePin = 2; // strobe is attached to digital pin 2
-
int resetPin = 3; // reset is attached to digital pin 3
-
int ledPin = A9;
-
int spectrumValue[7]; // to hold a2d values\
-
-
int point = 0;
-
-
-
void setup()
-
{
-
- // Serial.begin(28800);
-
-
pinMode(analogPin, INPUT);
-
pinMode(strobePin, OUTPUT);
-
pinMode(resetPin, OUTPUT);
-
pinMode(ledPin, OUTPUT);
-
analogReference(DEFAULT);
-
-
-
digitalWrite(resetPin, LOW);
-
digitalWrite(strobePin, HIGH);
-
-
for (int z = 0; z<1000 ; z++){
-
pastValues [z] = 80;
-
}
-
-
}
-
-
void loop()
-
{
-
digitalWrite(resetPin, HIGH);
-
digitalWrite(resetPin, LOW);
-
-
for (int i = 0; i < 7; i++)
-
{
-
digitalWrite(strobePin, LOW);
-
delayMicroseconds(30); // to allow the output to settle
-
spectrumValue[i] = analogRead(analogPin);
-
if (i == 0 ){
-
-
pastValues[point++] = spectrumValue[i];
- // Serial.print(spectrumValue[i]);
- // Serial.print ("L ");
-
if(point >1000)
-
point=0;
-
promedio();
-
-
//analogWrite(ledPin, (spectrumValue[i]/4) );
-
if (spectrumValue[i] >(limit)){
-
// digitalWrite(ledPin, HIGH);
-
// delay(25);
-
for (int y = 255;y>=0;y--){
-
analogWrite(ledPin,y);
-
delayMicroseconds(450);
-
}
-
}
-
else
-
analogWrite(ledPin, 0);
-
}
-
-
-
/*
- // comment out/remove the serial stuff to go faster
- // - its just here for show
- if (spectrumValue[i] < 10)
- {
- Serial.print(" ");
- Serial.print(spectrumValue[i]);
- }
- else if (spectrumValue[i] < 100 )
- {
- Serial.print(" ");
- Serial.print(spectrumValue[i]);
- }
- else
- {
- Serial.print(" ");
- Serial.print(spectrumValue[i]);
- }
- */
-
-
digitalWrite(strobePin, HIGH);
-
}
-
-
}
-
-
void promedio (){
-
unsigned long suma = 0;
-
for (int z = 0; z <=1000;z++){
-
suma+=pastValues[z];
-
}
-
limit = suma/1000.0;
-
limit= limit*1.75;
-
// Serial.println(limit);
-
}
-
-
-
-
-
-
-
-
- #include "RunningAverage.h"
-
-
RunningAverage bajos(1000);
-
int analogPin = A0; // read from multiplexer using analog input 0
-
int strobePin = 2; // strobe is attached to digital pin 2
-
int resetPin = 3; // reset is attached to digital pin 3
-
int ledPin = A9;
-
int spectrumValue[7]; // to hold a2d values\
-
-
-
void setup()
-
{
-
-
Serial.begin(9600);
-
bajos.clr();
-
pinMode(analogPin, INPUT);
-
pinMode(strobePin, OUTPUT);
-
pinMode(resetPin, OUTPUT);
-
pinMode(ledPin, OUTPUT);
-
analogReference(DEFAULT);
-
-
-
digitalWrite(resetPin, LOW);
-
digitalWrite(strobePin, HIGH);
-
-
}
-
-
void loop()
-
{
-
digitalWrite(resetPin, HIGH);
-
digitalWrite(resetPin, LOW);
-
-
for (int i = 0; i < 7; i++)
-
{
-
digitalWrite(strobePin, LOW);
-
delayMicroseconds(30); // to allow the output to settle
-
spectrumValue[i] = analogRead(analogPin);
-
if (i == 0 ){
-
-
bajos.add(spectrumValue[i] );
-
Serial.println(bajos.avg());
-
//analogWrite(ledPin, (spectrumValue[i]/4) );
-
if (spectrumValue[i] >(bajos.avg()*2)){
-
// digitalWrite(ledPin, HIGH);
-
// delay(25);
-
for (int y = 255;y>=0;y--){
-
analogWrite(ledPin,y);
-
delayMicroseconds(450);
-
}
-
}
-
else
-
analogWrite(ledPin, 0);
-
}
-
-
-
/*
- // comment out/remove the serial stuff to go faster
- // - its just here for show
- if (spectrumValue[i] < 10)
- {
- Serial.print(" ");
- Serial.print(spectrumValue[i]);
- }
- else if (spectrumValue[i] < 100 )
- {
- Serial.print(" ");
- Serial.print(spectrumValue[i]);
- }
- else
- {
- Serial.print(" ");
- Serial.print(spectrumValue[i]);
- }
- */
-
-
digitalWrite(strobePin, HIGH);
-
}
-
Serial.println();
-
}
-
-
-
-
-
-
-
int analogPin = A0; // read from multiplexer using analog input 0
-
int strobePin = 2; // strobe is attached to digital pin 2
-
int resetPin = 3; // reset is attached to digital pin 3
-
int ledPin = A9;
-
int spectrumValue[7]; // to hold a2d values\
-
-
-
void setup()
-
{
-
Serial.begin(9600);
-
pinMode(analogPin, INPUT);
-
pinMode(strobePin, OUTPUT);
-
pinMode(resetPin, OUTPUT);
-
pinMode(ledPin, OUTPUT);
-
analogReference(DEFAULT);
-
-
-
digitalWrite(resetPin, LOW);
-
digitalWrite(strobePin, HIGH);
-
-
Serial.println("MSGEQ7 test by J Skoba");
-
}
-
-
void loop()
-
{
-
digitalWrite(resetPin, HIGH);
-
digitalWrite(resetPin, LOW);
-
-
for (int i = 0; i < 7; i++)
-
{
-
digitalWrite(strobePin, LOW);
-
delayMicroseconds(30); // to allow the output to settle
-
spectrumValue[i] = analogRead(analogPin);
-
if (i == 0 ){
-
//analogWrite(ledPin, (spectrumValue[i]/4) );
-
if (spectrumValue[i] >124){
-
// digitalWrite(ledPin, HIGH);
-
// delay(25);
-
for (int y = 255;y>=0;y--){
-
analogWrite(ledPin,y);
-
delayMicroseconds(500);
-
}
-
}
-
else
-
analogWrite(ledPin, 0);
-
}
-
-
// comment out/remove the serial stuff to go faster
-
// - its just here for show
-
if (spectrumValue[i] < 10)
-
{
-
Serial.print(" ");
-
Serial.print(spectrumValue[i]);
-
}
-
else if (spectrumValue[i] < 100 )
-
{
-
Serial.print(" ");
-
Serial.print(spectrumValue[i]);
-
}
-
else
-
{
-
Serial.print(" ");
-
Serial.print(spectrumValue[i]);
-
}
-
-
-
digitalWrite(strobePin, HIGH);
-
}
-
Serial.println();
-
}
-