Offline
Newbie
Karma: 0
Posts: 23
|
 |
« on: December 06, 2012, 05:58:53 pm » |
Serial.write(argument); Serial.println(argument); etc.
Is there anyway to continuously send data from the pc to the computer?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #1 on: December 06, 2012, 06:02:14 pm » |
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
Newbie
Karma: 0
Posts: 23
|
 |
« Reply #2 on: December 06, 2012, 06:09:28 pm » |
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
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #3 on: December 06, 2012, 06:12:39 pm » |
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
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #4 on: December 06, 2012, 06:14:23 pm » |
So could I write a program in C that sends data to the Arduino Yes. 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. How does that work? It doesn't.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 23
|
 |
« Reply #5 on: December 06, 2012, 06:36:35 pm » |
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)
Online
Brattain Member
Karma: 279
Posts: 15308
Measurement changes behavior
|
 |
« Reply #6 on: December 06, 2012, 06:39:59 pm » |
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
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #7 on: December 06, 2012, 06:40:45 pm » |
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
Newbie
Karma: 0
Posts: 23
|
 |
« Reply #8 on: December 06, 2012, 06:47:47 pm » |
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
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #9 on: December 06, 2012, 06:51:27 pm » |
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: d13=1
and later to turn it off you would send: d13=0
-br
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #10 on: December 06, 2012, 06:52:28 pm » |
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
Newbie
Karma: 0
Posts: 23
|
 |
« Reply #11 on: December 06, 2012, 06:57:18 pm » |
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
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #12 on: December 06, 2012, 07:03:31 pm » |
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
Newbie
Karma: 0
Posts: 23
|
 |
« Reply #13 on: December 06, 2012, 07:15:57 pm » |
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
God Member
Karma: 37
Posts: 974
Get Bitlash: http://bitlash.net
|
 |
« Reply #14 on: December 06, 2012, 07:27:33 pm » |
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. 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. 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. 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
|
|
|
|
|
|