Pages: [1] 2   Go Down
Author Topic: Arduino Result to text file  (Read 2304 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hiii i need to know how to save my Arduino Uno distance Results into a Text File in order to display the result in an android application, that the Arduino board is connected to the pc via USB?? Any help?
Logged

0
Offline Offline
Edison Member
*
Karma: 7
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There are many ways to do that:
1. save the data on SD card (text file);
2. send data through Bluetooth directly to your Android app;
3. send data through USB (serial port) to PC.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot but i don't have SD Card nor Bluetooth connected to the Arduino Board , So Am using USB , but the problem is i am not understanding how , I found this code
 http://timewitharduino.blogspot.com/2009/05/getting-arduino-to-write-to-or-read.html , but I can't understand it or determine if it is useful or not can you explain it or sth ? . thanks again ...
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11179
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What operating system does the PC run? If it's Microsoft Windows, you can use Gobetwino to write data supplied by the Arduino to a file on the PC. I'm not clear how you would get it from there to the Android, but since you don't seem to have provided any other way to get the data off the Arduino, getting it onto a file the PC would seem to be a useful first step.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 5
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

GoBetwino can run on your PC and ave data coming from Arduino to a txt file on the PC.
Logged

0
Offline Offline
Edison Member
*
Karma: 7
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The code you linked to is a VB script (running on Windows) that reads characters on a COM (serial) port and saves them to the specified file.
Did you try running it? What part of the code you don't understand?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have downloaded GobetWino but I didn't understand how it functions well ..
and Florinc I understand the code but i keep getting "An unhandled exception of type 'System.IO.FileNotFoundException' occurred in DataReader.exe" while running !! and I can't figure out how to solve it ... can you help?
Logged

0
Offline Offline
Edison Member
*
Karma: 7
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What version of Windows are you running on?
What COM port are you using?
Can you post your code?
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 5
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you check the sample code that comes with GoBetwino you can find an example of how to log data to a txt file on the PC.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am running on Windows 7, using Com Port 25 and here is my code
Imports Scripting
Imports System.Threading.Thread
Imports System.Windows.Forms.SendKeys



Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Try
            Const ForReading = 1
            Const ForWriting = 2
            Dim fso

            Dim com
            Dim objFSO
            Dim objFile
            Dim s

            Dim WShell

            WShell = CreateObject("WScript.Shell")
            fso = CreateObject("Scripting.FileSystemObject")
           
            com = fso.OpenTextFile("COM25:9600,N,8,0", ForReading)




            objFSO = CreateObject("Scripting.FileSystemObject")
            objFile = objFSO.OpenTextFile("D:\Data.txt", ForWriting, True)

            MsgBox("Start to read data from COM")

            Do While com.AtEndOfStream <> True
                s = com.ReadLine
                objFile.WriteLine(s)
                System.Threading.Thread.Sleep(100)
            Loop

            objFile.Close()
            com.Close()

        Catch
            MessageBox.Show("Unable to read file ")
        End Try

    End Sub
End Class


Iactually used it from this site : http://timewitharduino.blogspot.com/2009/05/getting-arduino-to-write-to-or-read.html
I keep getting file not found, the error is on line :com = fso.OpenTextFile("COM25:9600,N,8,0", ForReading)
thanks a lot

And for the Gobetwino I found out that it doesn't work on Windows 7 that's why it couldn't run on my pc ... thanks !!1 smiley
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11179
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And for the Gobetwino I found out that it doesn't work on Windows 7 that's why it couldn't run on my pc ... thanks !!1 smiley

I am running it on Windows 7.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thats Greaaat!! then could you help me understand how to use it??? it didn't work for me,I guess I was using it wrong then !
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 5
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I dont' think there' any problem running GoBetwino on Window 7.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11179
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What have you done so far?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

0
Offline Offline
Edison Member
*
Karma: 7
Posts: 1411
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

According to this microsoft article
http://support.microsoft.com/kb/115831
COM ports higher than 9 are named like this: \\.\COM10

I don't have windows 7 to test it, but I think it will work if you change the line to:
Code:
  com = fso.OpenTextFile("\\\\.\\COM25:9600,N,8,0", ForReading)
Logged

Pages: [1] 2   Go Up
Jump to: