We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, something is wrong with "String port = Serial.list()[numero_port_serie];" but i don't know where is the problem Is someone able to answer me ? Error : ArrayIndexOutOfBoundsexception:21
import processing.serial.*; import controlP5.*; ControlP5 cp5; Serial serial; float n; String[] lines;
void setup() { //*************************************************** //* Lecture fichier .txt disponible depuis lines[i] lines=loadStrings("test.txt");
//************************************************
//*Ouverture et test des ports com USB
println("Voici la liste des ports :");
println(Serial.list());
int numero_port_serie = 21; // Attention ici à regarder dans la liste pour choisir le bon PORT COM !!!
print("Le numero de port est : ");
println(numero_port_serie);
String port = Serial.list()[numero_port_serie];
print("Le port est : " );
println(port);
serial = new Serial(this ,port ,9600); // attention même vitesse à régler dans le source Arduino !!!
size(400,400);
//********************************************* //* Création d'un bouton de control cp5 = new ControlP5(this); cp5.addButton("Valide lecture Arduino", 0, 0, 0, 80, 19).setValue(0).setPosition(50,90).setSize(100,19); cp5.setPosition(100,100); }
void draw() {
} //********************************************* //* Gestion des événements au click sur lebouton public void controlEvent(ControlEvent theEvent) { lines=loadStrings("test.txt"); for (int i = 0 ; i < lines.length; i++) { println(lines[i]); // Affiche la donnée qui va être transférée à l'arduino serial.write(lines[i]); // Transfert vers l'aduino les données du fichier. } }
Answers
Try [0] or look at the reference
21 might be too high for the serial List
yeah, now the problem is with " serial = new Serial(this ,port ,9600);" :S
Please edit your post, select your code and hit ctrl+o to format your code. Make sure there is an empty line above and below your code
Kf
And a better topic title won't hurt.
I have changed the topic title and I suggest that you fix the formatting of the code.
Also
responses like this are absolutely useless what is the error message :-?