Arduino project

Raspberry project

Post Page Advertisement [Top]

This example will show how to send/receive String from Arduino to computer (PC) through COM (UART) Port

Make program as here (download at this link - Google share):
String mySt;
char myChar = 0;

void setup() {
  // start serial port at 9600 bps:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

  establishContact();  // send a byte to establish contact until receiver responds

void loop() {
  if (Serial.available() > 0) {
    myChar =;
    mySt +=myChar;
  if ((mySt.length() >0)&(!Serial.available())) {
void establishContact() {
  while (Serial.available() <= 0) {
    Serial.println("Send me something");

After download program, open Serial monitor from IDE: tool > Serial Monitor (or press Shift+CTL+M)
Configure COM port in the Monitor with exactly baudrate (if wrong, it will show something can't be read for human)
In this example, sentence "Send me something" will be shown in every 3 seconds. It will stop when a sentence is sent from text box.


  1. This comment has been removed by the author.

  2. Thanks, You wrote awesome, I have learn lots of things from your article. It's really helpful for any readers.
    Battery Operated Flow Meter

  3. Thanks for posting the useful information.
    Manasmeter supply flow meter at affordable price. We sale best gas flow meter, digital gas flow meter, and steam flow meter at cheap cost.
    gas flow meter - Manasmicro

  4. Hi
    I am using a spark fun red board and I get a com of 51. In what file do I need to change the com port from 4 to 51
    many thanks


Bottom Ad [Post Page]