here is my problem. i am making a machine that java program controls arduino by Serial.read() function of arduino.
?n order to communicate with arduino i used "Printwriter and get outputstream".
my question is: "why i can send just one command when i clicked the button? I want to send that each listmember in that arraylist one by one"
how can i do it please help
private void otomatikmoddenemebutonuActionPerformed(java.awt.event.ActionEvent evt) {
try {
BufferedReader bufReader = new BufferedReader(new FileReader("E:\DenemeOtomatikKomutlar.txt"));
ArrayList<String> listOfLines = new ArrayList<>();
String line = bufReader.readLine();
while (line != null) {
listOfLines.add(line); line = bufReader.readLine();
PrintWriter output = new PrintWriter(chosenPort.getOutputStream());
for (int i = 0; i < listOfLines.size(); i++) {
output.println(listOfLines.get(i));
output.flush();
otodenemeTF.setText(listOfLines.get(3));
}
}
bufReader.close();
} catch (FileNotFoundException ex) {
Logger.getLogger(PaintMixer_JogModu.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(PaintMixer_JogModu.class.getName()).log(Level.SEVERE, null, ex);
}
}
question from:
https://stackoverflow.com/questions/65625811/printwriter-i-can-send-only-first-of-my-commands-to-serial-of-arduino 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…