Hello. Working on a project for school. We intend to use Duemilanoves with transceivers to send GPS data over a channel. But to start, we are trying to just get one to receive "Hello World" from the other. I just cant seem to get good output, its always garbage. Someone please tell me what is wrong with this code:
Sender:
#include <AFSoftSerial.h>
#include <SoftwareSerial.h>
#define ledPin 13
AFSoftSerial mySerial = AFSoftSerial(3, 2);
byte pinState = 0;
void setup()
{
Serial.begin(9600);
// set the data rate for the SoftwareSerial port
mySerial.begin(2400);
//mySerial.println("Hello, world...");
}
void loop() // run over and over again
{
mySerial.println("Hello, world...");
delay(300);
toggle(ledPin);
}
void toggle(int pinNum) {
// set the LED pin using the pinState variable:
digitalWrite(pinNum, pinState);
// if pinState = 0, set it to 1, and vice versa:
pinState = !pinState;
}
Receiver
#include <AFSoftSerial.h>
#include <SoftwareSerial.h>
AFSoftSerial mySerial = AFSoftSerial(3, 2);
void setup()
{
Serial.begin(9600);
// set the data rate for the SoftwareSerial port
mySerial.begin(2400);
// Serial.println("Hello, world...");
}
void loop() // run over and over again
{
if (mySerial.available() > 0)
{
Serial.println(mySerial.read());
}
}