I'm sorry if this has been beat to death but searching only comes up with similar questions but usually talks about shields but I would like to send simple strings to the arduino using the onboard usb connection from a PC, and then send status strings back. Is this possible or is that one just hooked up to put the microcontroller in programming mode to burn the data?
And forgot to add if it makes a difference, it will have a RAMPS shield on it.
The USB connection to the PC provides a serial link over which messages can be sent both ways, as used by the Serial monitor, or do you want an actual USB connection ?
Serial is normally connected via USB, you can open monitor on the same port and send data back and forth, provided Serial baud rate matches
I figured so but haven't seen any basic examples except for using the I/O pins. I'm familiar with PIC controllers but never used arduinos. Does anyone have any links to simple sketch examples? I develop in .net so I have the PC side down. But yes, normal serial coms from the onboard USB is what I would need. From the PC side I would open COM4.Send("MYString").
See Serial input basics - updated for ideas on how to receive and parse data with an Arduino serial link. Sending data to the PC is easy, just Serial.print() it and off it goes
One thing to note is that opening the Serial link to most Arduinos causes them to reset so take that into account. Which Arduino do you have ?
I have the Mega 2560. Those examples are great, so I assume unless I define another I/O, serial just defaults to the USB connection?
Serial (capital S) defaults to the USB serial link. The Mega has 3 other hardware UARTS available on its pins and these are referred to as Serial1, Serial2 and Serial3 but you will need external hardware to communicate with the PC to convert the TTL signals to serial voltage levels that the PC can use. They can be handy because it allows you to use one serial interface to communicate and another for debugging
That is good to know thank you, this will make it much easier. I'm use to using the UARTS and a MAX232. I might use the other UARTS to connect more arduinos together to share info due to the machine I am building multitasking.
Don't dismiss the possibility of multitasking on a single Arduino
I'm sure I will put it to good use, but there will be several stations in the machine with LEDs, sensors, servos, steppers, and then feeding into a machine that connects to it being controlled by different software.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.