I'm having difficulties with reading an array from a text file (segg.txt) .
I will try to explain what i'm trying to do, but i am a complete programming noob :(.
So i have a text file with data in it that looks like this:
What i'm trying to accomplish is the following:
Each note (C, C#, D, D#, E, F, F#, G, G#, A, A#, B) i would like to link a led connected to an arduino (i have already uploaded the firmata to arduino).
When a note hits "1" at a certain point of time (timepoint) i would like the corresponding led to turn on. Offcourse this led turns off when the next note is playing.
I have found that i can read the text file with following code:
String[] lines = loadStrings("segg.txt");
println("there are " + lines.length + " lines");
for (int i=0; i < lines.length; i++) {
println(lines[i]);
}
However this will just print out the entire text file, but it will not divide the array's parameters.
I REALLY hope someone can help me with this! :(
Here is some code that describes which arduino outputs i am using:
Arduino arduino;
int trilmodule1 = 30;
int trilmodule2 = 31;
int trilmodule3 = 32;
int trilmodule4 = 33;
int trilmodule5 = 36;
int trilmodule6 = 37;
int trilmodule7 = 38;
int trilmodule8 = 39;
int trilmodule9 = 40;
int trilmodule10 = 41;
int trilmodule11 = 42;
arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(trilmodule1, Arduino.OUTPUT);
arduino.pinMode(trilmodule2, Arduino.OUTPUT);
arduino.pinMode(trilmodule3, Arduino.OUTPUT);
arduino.pinMode(trilmodule4, Arduino.OUTPUT);
arduino.pinMode(trilmodule5, Arduino.OUTPUT);
arduino.pinMode(trilmodule6, Arduino.OUTPUT);
arduino.pinMode(trilmodule7, Arduino.OUTPUT);
arduino.pinMode(trilmodule8, Arduino.OUTPUT);
arduino.pinMode(trilmodule9, Arduino.OUTPUT);
arduino.pinMode(trilmodule10, Arduino.OUTPUT);
arduino.pinMode(trilmodule11, Arduino.OUTPUT);
void resetSensors() {
arduino.digitalWrite(trilmodule1, Arduino.LOW);
arduino.digitalWrite(trilmodule2, Arduino.LOW);
arduino.digitalWrite(trilmodule3, Arduino.LOW);
arduino.digitalWrite(trilmodule4, Arduino.LOW);
arduino.digitalWrite(trilmodule5, Arduino.LOW);
arduino.digitalWrite(trilmodule6, Arduino.LOW);
arduino.digitalWrite(trilmodule7, Arduino.LOW);
arduino.digitalWrite(trilmodule8, Arduino.LOW);
arduino.digitalWrite(trilmodule9, Arduino.LOW);
arduino.digitalWrite(trilmodule10, Arduino.LOW);
arduino.digitalWrite(trilmodule11, Arduino.LOW);
// PARTICLE / PITCH (locatie van particle)
// HIER VIBREREN
if (physics.numberOfParticles() < MAX_PARTICLES ) {