-2

I have used a msgeq7 chip with an arduino to split audio from a audio jack all connected on a breadboard. I have code which shows the 7 different frequencies with each having a value of 'loudness' that strobes rapidly. I was wondering if anyone knew how I could use this data from the arduino to create a graphical spectrum in c# for example? Nothing too complicated just a 7x6 grid with green dots at the bottom and red dots near the top that go up and down to help visualize loudness. Anyone help?

Conz
  • 11
  • 1

1 Answers1

1

I don't know about c# but you can hop on over to processing https://processing.org/ which is built on java but easy to get the hang of. You can use processing to establish a serial connection with your Arduino and send data between them and then render out the data in processing however you see fit.

Sample Arduino Code:

void setup() {
  Serial.begin(9600);
  Serial.setTimeout(20);
  delay(100);
}

void loop() {
//send data over serial port
    Serial.println("Hello World");
    delay(50);
}

Processing Code:

import processing.serial.*;

Serial myPort;
String val;

void setup() {
  smooth();
  size(300, 350);
//you may have to mess around with the value in brackets to get the right on.
//Try printling out all values in Serial.list() and find your Arduino port name
  String portName = Serial.list()[3];
  println(portName);
  myPort = new Serial(this, portName, 9600);
  myPort.bufferUntil('\n');
}

void draw(){
    //draw stuff
}

void serialEvent( Serial myPort) {
  //put the incoming data into a String - 
  //the '\n' is our end delimiter indicating the end of a complete packet
  val = myPort.readStringUntil('\n');
  //make sure our data isn't empty before continuing
  if (val != null) {
    //trim whitespace and formatting characters (like carriage return)
    val = trim(val);
    println(val);
  }
}

Hopefully this should get you started. Most of this information is from the Sparkfun Arduino Processing tutorial https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing so take a look at it if you have any more questions.

Dan12-16
  • 351
  • 1
  • 8