All pastes #1583895 Raw Edit

Arduino Equalizer

public cpp v1 · immutable
#1583895 ·published 2009-09-29 07:24 UTC
rendered paste body
//analog pins on my arduino.//Each pin will represent a frequency bar int pins[]  ={3,5,6,9,10,11};//initialisationvoid setup() {  //begin serial communication (usb)  Serial.begin(9600);  Serial.flush();    //initialise all lights  for (int i=0;i<13;i++) {    pinMode(i,OUTPUT);     analogWrite(i,0);  }  }//main loopvoid loop() {  //Note:  //The audio information comes from a processing sketch  //The sketch analyses in the incoming audio from my microphone  //It then sends the data to arduino, always as a pair of int values:  //Value 1 = the id of the pin (0-5);  //Value 2 = the value of the frequency (0-255)  while (Serial.available()>1) {    int id = Serial.read();    int value = Serial.read();    analogWrite(pins[id],value);  }  delay(50);}