Pessoal, alguém tem alguma dica de como gravar em um arquivo TXT usando arduino?
Achei esse codigo na internet, mas não estou conseguino compilar, e não estou conseguindo resolver o erro..
/**
* Analog In
*
* Reads a value from the serial port and sets the background color.
* Running this example requires you have a BX-24 microcontroller
* and peripheral hardware. More information can be found on the tutorial
* pages of Tom Igoe: http://stage.itp.nyu.edu/~tigoe/pcomp/examples.shtml
* Because this program uses the serial port, it will not work within a web browser.
*
* Temperature collecting and writing to a text file
*/
import processing.serial.*;
String buff = "";
int val = 0;
int NEWLINE = 10;
int i = 0 ;
PFont font;
Serial port;
PrintWriter output;
void setup()
{
size(250, 200);
background(255, 204, 0);
font = loadFont("UniversLTStd-Light-48.vlw");
textFont(font, 32);
// Print a list in case COM1 doesn't work out
println("Available serial ports:");
println(Serial.list());
//port = new Serial(this, "COM1", 19200);
// Uses the first available port
port = new Serial(this, Serial.list()[0], 9600);
output = createWriter("temperaturas.txt"); // cria arquivo para armazenar as temperaturas
}
void draw()
{
while (port.available() > 0) {
serialEvent(port.read());
}
}
void keyPressed() { // Press a key to save the data
output.flush(); // Write the remaining data
output.close(); // Finish the file
exit(); // Stop the program
}
void serialEvent(int serial)
{
// If the variable "serial" is not equal to the value for
// a new line, add the value to the variable "buff". If the
// value "serial" is equal to the value for a new line,
// save the value of the buffer into the variable "val".
println(serial) ;
val=serial ;
// Escreve a temperatura e a hora
//
output.println(hour() + ":" + minute() + ":" + second() + "," + val);
//line(i,200,i,200-(val*4)) ; // funciona bem para a linha
fill(102,0,153) ;
rect(i,200-(val*4),2,val*4) ; // desenha a barra temperatura
fill(255, 204, 0) ;
noStroke() ; // nao desenha a borda do retangulo .
rect(110,5,50,30) ; // apaga o texto anterior
fill(102,0,153) ;
text(val, 125, 30);
fill(0, 102, 153);
i+=6 ; // se chegar ao limite da area de desenho , apaga tudo e recomeça
if(i>=250) {
i=0 ;
background(255, 204, 0);
}
}