Arduino + Processing (Save to TXT)
I wonder if someone could help me in programming to write the data to a notepad, file. Txt
What I want is to record the voltage value to a block of text, along with the date and time, then the tension on the door handles analog Arduino.
Until now able to develop the following code:
- import date;
import processing.serial. * / / Import the communication library series
Serial myport;/ / Creates an object for communication
SensorReading String = "";
PFont font;
PrintWriter output; / / write the data received by the port
void setup ()
{
size (400.200) / / Sets the window size
myport = new Serial (this, "COM4", 9600); / / Connect to COM4
myPort.bufferUntil ('\ n') / / Wait for receiving the first signal from usb
font = CreateFont (PFont.list () [2], 32);
textFont (font);
CreateWriter output = ("C: \ Users (x86) / alunosdefi / Desktop / data.txt") / / creates the text file in this way
}
void draw ()
{
/ / Do not do anything but it is necessary to declare
}
void serialEvent (Serial myport)
{
sensorReading myPort.readStringUntil = ('\ n') / / Get the first line received on the serial port
if (sensorReading! = null)
{/ / If the line is not blank
sensorReading = trim (sensorReading) / / removes whitespace
/ / Remove whitespace
{
output.println (second () + "\ t" + sensorReading) / / writes the second tab and the value of the stress-strain tab value y
output.flush () / / writes all the data in the file
WriteText ("Sensor Reading:" + sensorReading);
}
void WriteText (String textToWrite)
{/ / Displays the values of tension in a new window with the format defined above WriteText
background (255); / / background color of the window
fill (0);
text (textToWrite, width/20, height / 2); }
I'm getting the error: "unexpected char 'U', the line output = creatWriter (" ").
Furthermore, as I mentioned, I would write the data to a notepad with Date - Time and value of voltage.
If it were possible I would like to know if you can set how often you can send the data to the notebook, as I wanted to send 3 in 3 minutes.
Thanks for listening,
Pedro Santos