1

I need to send some information from my PC to an Arduino. I tested it with PuTTY and it works great.

I need to send characters, '1' or '2', to control a servo and I am using these commands:

mode com10:9600,n,8,1

... and I see that my Arduino received some data.

After that, I try to use that:

echo 1>com10

OR

echo "1">com10

and nothing nothing happens.

With PuTTY it works corrent and turning, when I press 1 or 2. With the Arduino serial monitor it works great too.

2
  • Do you press the Enter key in putty? Commented Feb 12, 2012 at 9:31
  • echo 1 >> \\.\COM10 Commented Sep 18, 2017 at 18:41

6 Answers 6

2

What worked for me was, something like:

echo ON > \\.\COM4
echo OFF > \\.\COM4

This link provides some good info.

So, in general, the format to send simple ASCII chars to serial port:

echo [ASCII chars / string you want to send]    >       \\.\    [Com Port #]
Sign up to request clarification or add additional context in comments.

Comments

1

At the end, I used PowerShell to do this task:

powershell "$port= new-Object System.IO.Ports.SerialPort COM10,9600,None,8,one; $port.open(); $port.WriteLine("1"); $port.Close()"

1 Comment

I had tried PHP, C++, Python, and countless modes with no avail. Your solution worked for me under Windows 7. Thank you
1

PowerShell is very useful when working with Arduinos, here is a link to a post where I did the same.

I've added a COM port lookup and some error handling to ease the process. Hope this helps someone.

Comments

1

mode com3 BAUD=9600 PARITY=n DATA=8 STOP=1 && echo blahblah > com3


about the same:


powershell "$port= new-Object System.IO.Ports.SerialPort COM10,9600,None,8,one; $port.open(); $port.WriteLine("1"); $port.Close()"

Comments

0

This will send the contents of a file to COM10 under Windows 7, not sure about other versions:

copy myfile \\.\COM10

If you just use "copy myfile COM10" then it creates a file called COM10 instead.

So you might like to try:

echo 1>\\.\com10

Comments

-1

Three points:

  1. COM10 isn't a reserved file name like COM1–4, so it could be that you're just creating a file.
  2. echo 1>foo is the same as echo >foo which will print ECHO is on. (you're redirecting stream 1, aka stdout).
  3. echo "1">foo will print "1" including the quotes.

To actually echo a 1 somewhere you'd have to use

>foo echo 1

or

(echo 1)>foo

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.