I am connecting an LDR (light dependent resistor) to a digital pin on Arduino (digital pin 8 ). I am receiving digital values from this sensor (1 for sensing light, and 0 for darkness). I am trying to log this data of the LDR sensor to a text file on my computer (Microsoft vista). I can view the values using the serial monitor in the Arduino IDE, but I want to log it to a text file also. I tried to use processing language and IDE to read data from the serial port and write it to a text file and I downloaded the processing IDE and got some code but all I got was an empty text file in the same directory.
Please tell me how can I log this sensor's data to a text file on my PC. My Arduino is connected to port "COM4".
This is my Arduino code:
note: in this code I used an LED and pin 13 to just give me a visual output. When it is light, the LED shines, when it is dark, the LED is off.
or create your own serial program using c# /vb.net / c++ / pyhton /
python is free, for the others there exist express editions who are also free
python with the right library added to it, is most likely the essayist program to use since its a much higher language.
on modern PC the slowness of higher programs isnt a big problem.
I would recommend to output some special character after your value. For example, CR or LF. In this case the program on the PC side will know how to extract data from a common data flow.
or you may use my program for free
as a bonus it also does speak :)) (voice tested under win 7, i asume works also on xp but not sure)
its not completely foolproof written, and asumes a directory c:\temp ,,.. you can change it but be sure the folder does exist, or programs stops.
it also asumes you use serial.printline
I wrote a small program so you can used it. FOR XP ONLY
Small note:pay attention when you choose the programm speed, if your arduino runs at 100ms a loop choose for the program just the half -->50ms
when you choose the "overwrite option" take "true"
at least the file appears after you close the program.