maintenant, je veux envoyer les valeurs enregistrés dans un fichier .txt vers la carte arduino
le code processing:
import processing.serial.*;
BufferedReader reader;
String line;
int i;
Serial myport;
int j;
int donnee=57;
int[] touche=new int[4];
int teste=0;
int c=57;
int x;
int w;
void setup()
{
println(Serial.list());
myport=new Serial(this,Serial.list()[0],9600);
println("\n \n TRANSFERT DE DONNEES");
reader=createReader("I2.txt");
println("Veuillez entrer le code de verification :");
}
void draw()
{
if(teste==1&&donnee==57)
{
try{
line=reader.readLine();
}
catch(IOException e){
e.printStackTrace();
line=null;
}
int[] nums=int(split(line,''));
println(i);
for(int w=0;w<14;w++)
{
myport.write(nums[w]);
}
i++;
if(i==8192)
{
exit();
}
}
}
void serialEvent(Serial myport)
{
donnee=myport.read();
}
void keyPressed()
{
touche[x]=key;
x++;
if(x==4)
{
x=0;
if(touche[0]==(c) && touche[1]==(c-1) && touche[2]==(c-2) && touche[3]==(c-3))
{
println("\n------------- Acces Accepter --------------");
myport.write(touche[0]);
myport.write(touche[1]);
myport.write(touche[2]);
myport.write(touche[3]);
delay(10);
teste=1;
println("------------- Debut Du Transfert --------------");
}
else
{
println("Acces refuser");
}
}
}
le resultat obtenu :
[img][/img]Hors ligne