Is it possible to take, for instance, the serial readings over a period of 5 seconds and divide that by 5 to get the average... then stick that average number into a float?
I'm trying to visualize some data gathered via Arduino in Processing. Right now, the Arduino collects a string of numbers via EEG, all separated by commas. I'm just really confused at to what I should do in processing to get the program to use these separate numbers as variables in a visualization...... Can anyone shed some light?
Right now I have it so that Processing is able to print the serials form the Arduino:
import processing.serial.*; //import the Serial library
int end = 10;
String serial;
Serial port;
void setup() {
port = new Serial(this, Serial.list()[0], 9600);
port.clear();
serial = port.readStringUntil(end);
serial = null;
}
void draw() {
while (port.available () > 0) {
serial = port.readStringUntil(end);
}
if (serial != null) {
String[] a = split(serial, ',');
delay(100);
print("a[0] : ");
println(a[0]); //print Value1 (in cell 1 of Array - remember that arrays are zero-indexed)