How to write to a file?

Good day dear Arduino fans
I need help please tell me how to make the value of a variable written to a file on your computer ? Arduino connected to USB and identified as ком3
int echoPin = 9; 
int trigPin = 8; 
void setup() { 
Serial.begin (9600); 
pinMode(trigPin, OUTPUT); 
pinMode(echoPin, INPUT); 
} 
void loop() { 
int duration, cm; 
digitalWrite(trigPin, LOW); 
delayMicroseconds(2); 
digitalWrite(trigPin, HIGH); 
delayMicroseconds(10); 
digitalWrite(trigPin, LOW); 
duration = pulseIn(echoPin, HIGH); 
cm = duration / 58;
Serial.print(cm); 
Serial.println(" cm");
delay(1000);
}
July 2nd 19 at 13:30
3 answers
July 2nd 19 at 13:32
Solution
Arduino itself without a broker can't write to a file?
No, it can't, at least the standard Board, there is even a special driver not included, there simply emulates UART COM port and all. - mazie.Towne commented on July 2nd 19 at 13:35
Can not, but can theoretically Sabbath the data on the memory card that you pull up to a PC and then to analyze, but again you will have to write a program for the PC - caden_Wintheiser commented on July 2nd 19 at 13:38
But, like, can, SD card on spi porubitsya and write in a notebook right away, then insert the PC card and look at it - caden_Wintheiser commented on July 2nd 19 at 13:41
okay, thanks that responded - jaden_OKee commented on July 2nd 19 at 13:44
July 2nd 19 at 13:34
Need to write a program for a computer that will "listen" to the COM port, that is, to read him out of the team and work with the file, but the Arduino will send certain commands.
July 2nd 19 at 13:36
It will be necessary to write a program for a computer that will open a COM port with Arduino will be to read, simultaneously write data to a file. Language choose on taste, Qt, for example.
Can even will find that they are ready to read the COM port with the ability to write to the file.

_______
UPD:
You can add the SD card and write it in a notebook, then insert it into your PC and watch the data.

Find more questions by tags Arduino