Pages: [1]   Go Down
Author Topic: Making two boards talk  (Read 413 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, I've been trying to make two Diecimila boards talk to once another over serial.

I've written a simple script for the board that transmits. It simply counts up to 1,000 and loops.
The script on the receiver board is supposed to look for the number 200, and blink pin 13.

However, it's pretty buggy, and I'm not sure what's wrong.

I have TX from the transmit board going to RX in the receive board.
It transmits, however, pin 13 on the receiver end lights everytime it receives a number

Any help would be greatly appreciated.


Transmit code:

void setup() {
  //2400 baud for the 434 model
  Serial.begin(2400);
}
void loop(){
    for (int i=100; i< 1000; i=i+100) {
      Serial.print(i, DEC);
      Serial.print("\t");
      delay(1000);
    }
}


Receive code:

int incomingByte = 0;
int ledPin = 13;

void setup() {
  //2400 baud for the 434 model
  Serial.begin(2400);
}
void loop(){
  incomingByte = Serial.read();

  if (incomingByte == 200) {
    pinMode(ledPin, OUTPUT);  
    digitalWrite(ledPin, HIGH);   // sets the LED on
    delay(1000);                  // waits for a second
    digitalWrite(ledPin, LOW);    // sets the LED off
    delay(1000);                  // waits for a second

  }
  incomingByte = 0;
}




Thanks in advance!
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Your sending human numbers but the receiving end is expecting computer numbers. smiley

Best to make it count from 0 to 255 and remove the DEC from the serial print line.
Also remove the \t (optional - it doesnt matter). Then it should work correctly.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your help.

I tried what you said but it didn't work.

I'm wondering if I have to specify if the numbers are text?
Logged

Pages: [1]   Go Up
Jump to: