A
A
Alistair O2016-11-29 06:17:05
Arduino
Alistair O, 2016-11-29 06:17:05

How to write to a file?

Good day, dear Arduino fans,
I need help, please tell me how to make the variable values ​​​​be written to a file on the computer? arduino connected to usb and defined as com3

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);
}

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alister O, 2016-11-29
@box4

Rou1997 Alexander Gusev Can't Arduino write to a file without an intermediary?

R
Rou1997, 2016-11-29
@Rou1997

It is necessary to write a program for a computer that will "listen" to this COM port, that is, read commands from it and work with the file, well, and Arduino will send certain commands.

A
Alexander Gusev, 2016-11-29
@Sanchogus

It will be necessary to write a program for a computer that will open a COM port with an arduino and will read it, simultaneously writing data to a file. Choose the language of your choice, Qt, for example.
You may even find something ready to read the COM port with the ability to write to a file.
_______
UPD:
You can add an SD card and write to it in a notepad, then insert it into a PC and watch the data.

G
GreatRash, 2017-03-20
@Nwton

codepen.io/GreatRash/pen/peaPdj?editors=1010

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question