Pages: 1 [2]   Go Down
Author Topic: Serial Communication without computer?  (Read 2636 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
Karma: 548
Posts: 27372
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Read the VirtualWire document - it does not use the serial ports, it uses D11 & D12 as defualt, they can be changed.
Put the data you want in an array, it sends it  out. Here is heart of the code that would go in void loop().
There is more that goes in setup, read the document, the demo worked as-is for me sending characters. Very straightforward.
I reduced it a little as I was only sending 1 byte out.

#include <VirtualWire.h>    // Wireless transmitter/receiver library

    msg[0]=key;                               // load the array with the key character
    // msg[1]=NULL;                           // Rx side seems to work without this for me (I only send 1 byte from a keypad)

    digitalWrite(ledPin, true);               // Flash a light to show transmitting

    vw_send((uint8_t *)msg, strlen(msg));     // send the character out

//    Serial.println(key);                // for debugging only

    vw_wait_tx();                             // Wait until the whole message is gone
On the receive side:
// look for wireless input or for unsolicited message from arduino2

uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen)) // Non-blocking
  int i;
  digitalWrite(ledPin, LOW); // Turn on LED to show working a message

  // Message with a good checksum received, dump it.
  //Serial.println("Got: ");  // Show on PC for debugging

  //    for (i = 0; i < buflen; i++)
  //    {
  //    }
  //Serial.println(""); // spaces it out for the monitor


Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at
Arduino for Teens available at

Pages: 1 [2]   Go Up
Jump to: