Skip to main content
Arduino

Return to Question

Post Closed as "Not suitable for this site" by gre_gor, Community Bot, Chris Stratton, MatsK, jose can u c
added 1015 characters in body
Source Link

Data can be seen in the console but the data is not being written in the text file. The file is created but there is no data in it.

Here is my code in Processing,

enter image description here

import processing.serial.*;
Serial myPort; // Create object from Serial class
String val; // Data received from the serial port
PrintWriter output;
void setup()
{
 String portName = Serial.list()[0]; 
 myPort = new Serial(this, portName, 9600);
 output = createWriter( "my.txt" );
}
void draw()
{
 if ( myPort.available() > 0) 
 { // If data is available,
 val = myPort.readStringUntil('\n'); 
 output.print( val );
 } 
 println(val); //print it out in the console
 }

and in Arduino,

enter image description here

 int potPin = 0; // initialize analog pin 0 for LM35 temperature sensor
 void setup()
 {
 Serial.begin(9600);// set baud rate at"9600"
 }
 void loop()
 {
 int val;// define variable
 int dat;// define variable
 val=analogRead(0);
 dat=(125*val)>>8;// temperature calculation formula
 Serial.print("Tep:");//
 Serial.print(dat);// output and display value of dat
 Serial.println("C");// display "C" characters
 delay(500);// wait for 0.5 second
 }

Any answers are appreciated. Thank you!

Data can be seen in the console but the data is not being written in the text file. The file is created but there is no data in it.

Here is my code in Processing,

enter image description here

and in Arduino,

enter image description here

Any answers are appreciated. Thank you!

Data can be seen in the console but the data is not being written in the text file. The file is created but there is no data in it.

Here is my code in Processing,

import processing.serial.*;
Serial myPort; // Create object from Serial class
String val; // Data received from the serial port
PrintWriter output;
void setup()
{
 String portName = Serial.list()[0]; 
 myPort = new Serial(this, portName, 9600);
 output = createWriter( "my.txt" );
}
void draw()
{
 if ( myPort.available() > 0) 
 { // If data is available,
 val = myPort.readStringUntil('\n'); 
 output.print( val );
 } 
 println(val); //print it out in the console
 }

and in Arduino,

 int potPin = 0; // initialize analog pin 0 for LM35 temperature sensor
 void setup()
 {
 Serial.begin(9600);// set baud rate at"9600"
 }
 void loop()
 {
 int val;// define variable
 int dat;// define variable
 val=analogRead(0);
 dat=(125*val)>>8;// temperature calculation formula
 Serial.print("Tep:");//
 Serial.print(dat);// output and display value of dat
 Serial.println("C");// display "C" characters
 delay(500);// wait for 0.5 second
 }

Any answers are appreciated. Thank you!

Source Link

No data in text file

Data can be seen in the console but the data is not being written in the text file. The file is created but there is no data in it.

Here is my code in Processing,

enter image description here

and in Arduino,

enter image description here

Any answers are appreciated. Thank you!

default

AltStyle によって変換されたページ (->オリジナル) /