Pages: [1] 2   Go Down
Author Topic: Serial commands!  (Read 577 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Serial.write(argument);
Serial.println(argument);
etc.

Is there anyway to continuously send data from the pc to the computer?
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Presuming you meant "from the PC to the Arduino" there are many ways.  You write a program in your favorite language on the PC.

If you meant "from the Arduino to the PC", putting Serial.println() in loop() will cause it to be called Many Times Per Second.

-br
Logged

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

Haha, yes I'm sorry. I mean't from the PC to the Arduino. So could I write a program in C that sends data to the Arduino and then link it to the program in Arduino as a function from a library or something? How does that work?
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, no linking.  On the PC side you open the serial port and send characters to it.  On the arduino side you read one character at a time and parse it per your application.

Lots of examples if you search around a bit.

Be aware it's necessary to delay a short while after opening the serial port to allow the arduino bootloader to time out.  2 seconds is usually enough.  Otherwise the bootloader will swallow what you send and your program will appear to do nothing.

-br

Edit: If you want a ready-made receiver on the Arduino side you might check out Bitlash: http://bitlash.net

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So could I write a program in C that sends data to the Arduino
Yes.

Quote
and then link it to the program in Arduino as a function
No. The PC and the Arduino are running separate programs. You can't link the Arduino sketch into your PC application. That doesn't make sense.

Quote
How does that work?
It doesn't.
Logged

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

That's all a bit confusing. So there is no way, in an arduino sketch, to send information from the PC to the Arduino board without having to type it into the serial monitor?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's all a bit confusing. So there is no way, in an arduino sketch, to send information from the PC to the Arduino board without having to type it into the serial monitor?
Not quite, one however could say there is no way an arduino board can send or receive information on a PC other then via serial communications via a PC comm port. So any PC application program that can be programmed to work with a comm port can talk to a arduino board. The is how the Arduino IDE's serial monitor does it.

Lefty
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The serial monitor is just another program on the PC that opens and listens to the serial port and displays it on the screen.  Your program will listen to the serial port and send commands.  No serial monitor involved.

-br

Logged

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

I am very new at Arduino guys. Basically, what I'm trying to do is turn on an LED light if the arduino and PC are paired. But it seems that "there is no way to detect the bridge, only the cars on the bridge" so I am trying to continuously send data from the PC to the Arduino and then use Serial.read() to either return -1 to turn off the light, or something other than -1 to turn on the light because it is getting data from the PC. Any ideas? Be explicit please, I'm not always seeing the big picture when it comes to Arduino. And thank you
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It would help to know how you are sending the data from the pc...

Normally, continuous transmission is not needed.  For example, to turn on an LED on pin 13 using Bitlash, you would send:
Code:
    d13=1
and later to turn it off you would send:
Code:
  d13=0

-br
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Basically, what I'm trying to do is turn on an LED light if the arduino and PC are paired.
"Paired" in what way? Sending data to the Arduino via the serial port is one way for the Arduino to detect that there is something on the other end of the serial cable. Is that what you have between the Arduino and the PC?

Logged

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

I'm have them connected through bluetooth. I just want an LED to tell me when they are paired, and it to turn off it i rip the dongle off the pc. In such a case, I believe I need continuous data transmission from the PC to the Arduino, but I'm not sure how to achieve this using Arduino IDE... the only way I know of to send data PC ------> Arduino is either when I'm uploading the program or when I bring up the serial monitor and type in values. In which case I can get the light to turn on as the data is sending, then it turns off again when its done.
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To send data from the PC it is necessary to write a program on the PC in some PC-based targeted programming environment, not the Arduino IDE.  

There are examples in the Playground for many languages.

-br
« Last Edit: December 06, 2012, 07:05:37 pm by billroy » Logged

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

Can I get the COM3 (Arduino) and COM4 (PC) to talk to eachother using Arduino IDE? I haven't yet found a function that lets you mess with the COM ports. I know that if i do Serial functions i can go send a message from COM3 (Arduino) to COM4 (PC). Obviously the bluetooth chip on the Arduino is well aware of if it is paired with the PC. Why can't I access that and use it to turn on an LED?
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Can I get the COM3 (Arduino) and COM4 (PC) to talk to eachother using Arduino IDE?
1. The question makes no sense.  COM ports don't talk.
2. No.  You must write a program in a PC-targeted IDE, not the Arduino IDE.
Quote
I haven't yet found a function that lets you mess with the COM ports.
You won't, in the Arduino IDE.  You need to write a program in another IDE.
Quote
I know that if i do Serial functions i can go send a message from COM3 (Arduino) to COM4 (PC).
You can send and receive characters to any PC serial port from a program written for the PC, but not in the Arduino IDE.
Quote
Obviously the bluetooth chip on the Arduino is well aware of if it is paired with the PC. Why can't I access that and use it to turn on an LED?
This is straightforward to do once you know what you're doing talking to serial ports from the PC (in another programming environment than the Arduino IDE).  Most bluetooth interfaces have a command mode.  You put the module in command mode from the PC and ask for its status.


-br

Edit: too many examples to count here: http://playground.arduino.cc/Main/InterfacingWithSoftware

« Last Edit: December 06, 2012, 07:33:13 pm by billroy » Logged

Pages: [1] 2   Go Up
Jump to: