Audio Spactram Musical Lights

Audio Spactram Musical Lights



--------------------------- code -------------------------------------------------
int AudioIn=A0;
int LED1=9;
int LED2=8;
int LED3=7;
int LED4=6;
int LED5=5;
int LED6=4;
int LED7=3;
int LED8=2;
void setup() {
  // put your setup code here, to run once:
pinMode(LED1,OUTPUT);
pinMode(LED2,OUTPUT);
pinMode(LED3,OUTPUT);
pinMode(LED4,OUTPUT);
pinMode(LED5,OUTPUT);
pinMode(LED6,OUTPUT);
pinMode(LED7,OUTPUT);
pinMode(LED8,OUTPUT);
pinMode(AudioIn,INPUT);
Serial.begin(9600);
Serial.println("This is Audio Analiser");
}
void loop() {
  int A=analogRead(AudioIn);
  Serial.println(A);
 
  if(A>0&& A<20){digitalWrite(LED1,HIGH);}
  else if (A>20 && A<40) {digitalWrite(LED2,HIGH);digitalWrite(LED1,HIGH);}
  else if (A>40 && A<60) {digitalWrite(LED3,HIGH);digitalWrite(LED2,HIGH);digitalWrite(LED1,HIGH);}
  else if (A>60 && A<80) {digitalWrite(LED4,HIGH);digitalWrite(LED3,HIGH);digitalWrite(LED2,HIGH);digitalWrite(LED1,HIGH);}
  else if (A>80 && A<100) {digitalWrite(LED5,HIGH);digitalWrite(LED4,HIGH);digitalWrite(LED3,HIGH);digitalWrite(LED2,HIGH);digitalWrite(LED1,HIGH);}
  else if (A>80 && A<100) {digitalWrite(LED6,HIGH);digitalWrite(LED5,HIGH);digitalWrite(LED4,HIGH);digitalWrite(LED3,HIGH);digitalWrite(LED2,HIGH);digitalWrite(LED1,HIGH);}
  else if (A>100 && A<120) {digitalWrite(LED7,HIGH);digitalWrite(LED6,HIGH);digitalWrite(LED5,HIGH);digitalWrite(LED4,HIGH);digitalWrite(LED3,HIGH);digitalWrite(LED2,HIGH);digitalWrite(LED1,HIGH);}
  else if (A>120 && A<140) {digitalWrite(LED8,HIGH);digitalWrite(LED7,HIGH);digitalWrite(LED6,HIGH);digitalWrite(LED5,HIGH);digitalWrite(LED4,HIGH);digitalWrite(LED3,HIGH);digitalWrite(LED2,HIGH);digitalWrite(LED1,HIGH);}
  else{digitalWrite(LED1,LOW);
  digitalWrite(LED2,LOW);
  digitalWrite(LED3,LOW);
  digitalWrite(LED4,LOW);
   digitalWrite(LED5,LOW);
   digitalWrite(LED6,LOW);
   digitalWrite(LED7,LOW);
   digitalWrite(LED8,LOW);
  }
 
  delay(30);
  }

--------------------------------------------------------------------------------------------------------------------

1 comment:

Wifi Home automation Diy kit

 Wifi Home automation Diy kit By Manmohan Pal Wifi Home Automation Kit Hi, This is Manmohan Pal, I am glad to present a DIY kit for Home Aut...