TX2,RX2 on SPIDER board

IMAG1414.jpg

I am using SPIDER for next project to run 30 servos plus XBEE with voice/sound control.

Never work with 2nd TX/RX port on Arduino before and not to sure if I do this correctly. I have search on web and see how it should be setup in any easy I could understand and following code is what I found and modified a bit to start of:

#define sndSerial Serial1

void InitSnd(void){
    sndSerial.begin(9600);
}
void setup(){
  Serial.begin(9600);
  InitSnd();
}
void loop(){
  Serial.println("Serial");
  delay(500);
  sndSerial.println("Sound");
  delay(500);
}

The result only shows "Serial". Wondering which part goes wrong and hope anyone could give me a hand. Thank you!!

 

Try this

 

void setup(){

  Serial.begin(9600);

  Serial1.begin(9600);

}

 

void loop(){

  Serial.println(“Serial”);

  delay(500);

  Serial1.println(“Sound”);

  delay(500);

}

 

I don’t know much about arduinos, but,

a google search turned up Serial1.begin() rather than sndSerial.begin()

Might I add that I have

Might I add that I have never seen trying to name the serial port something other than Serial, Serial1, ect… (Besides with software serial)

Thanks for help. I tried

Thanks for help. I tried that but same. only “Serial” came up but not “Sound”. Seems like Serial1 is not working. Should I enable that timer or something? Maybe I missed something?

What do you mean by "only

What do you mean by “only shows Serial”? So you have 2 terminals open and are reading from each seperate port?

This is what I got in

This is what I got in pde:

void setup(){
  Serial.begin(9600);
  Serial1.begin(9600);
}
void loop(){
  Serial.println(“Serial”);
  delay(500);
  Serial1.println(“For Sound…”);
  delay(500);
}

I can only see “Serial Serial Serial…” but no “For sound…”. Should I define it ?

Are you trying to read both

Are you trying to read both of these througt the normal serial port? I am confused how you are set up to read what is being sent. If you are just using a single cable to your computer or multiple.

What I am trying to do…

I have SPIDER as Main board and XBee is using for wireless communication from other Arduino, in the mean time SPIDER is also sending the command to 3rd Arduino to handle all the sound/voice events. This is the first time I use multiple timer so I might go way so wrong in concept. If so please correct me for any idiot behavior :slight_smile:

Volt reg…

I may just be seeing things but…

Do you guys see what looks like a spot for a SMT volt reg right there on his X-bee adapter?

I couldn’t find that tiny

I couldn’t find that tiny one locally.

Step by step…

It sounds like you have 3 arduinos, 2 of which will later be connected with an x-bee, but are now connected with wires. You are also using the terminal to keep an eye on what is being sent. I am a bit confused as to what serial is going where but I think I can break this down a bit.

If the goal is to send a “command” from one arduino to the other, I would try to make this a LOT simpler. First off, start with just 2 arduinos. Program one that whenever it receives “65” it will blink a LED. Then wire it to the first serial port of the spider. TX to RX, Rx to TX, and connect grounds together. Now, send a “65” and see if you can get your LED to blink. If does not work, fix it. If it does, do the same thing, but use serial1 to transmit the “65” (you will have to move your wiring over to the serial1 pins).

Assuming these 2 tests work, you have eliminated a ton of stuff that “could be” the problem. You may now try a similar test but using both serials in the same sketch at the same time. Try to send 65 from serial and 66 from the other. Program the receiving arduino to do one blink for 65 and 2 blinks for 66. Now you know that both serials are working, the connections are right and the receiving code is working.

Next, add your X-bees and repeat the tests above again.

If you got this far, try sending more complicated data.

Thanks guys!!

First of all, it was stupid me for not wire Gnd.

2nd, I end up using <NewSoftSerial.h> and it works now.

Master(SPIDER):

void setup()  {
  Serial.begin(9600);
  Serial3.begin(9600);
}
void loop()  { 
  Serial.println(“on”);
  Serial3.print(“n”);
  delay(5000);
  Serial.println(“off”);
  Serial3.print(“f”);
  delay(5000);                           
}

 


 

Slave(Atmega328):

#include <NewSoftSerial.h>

NewSoftSerial mySerial(2, 3);
int c;
void setup()
{
  pinMode(12,OUTPUT);
  pinMode(13,OUTPUT);
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop()  { 
  while (mySerial.available() < 1) {}
   
  c = mySerial.read();
  Serial.println©;
  if(c==‘n’){
    digitalWrite(12,HIGH);
    digitalWrite(13,LOW);
  }else{
    digitalWrite(12,LOW);
    digitalWrite(13,HIGH);
  }
}

 


So the result is :Serial3 on SPIDER is sending data to newSerial pin3 on slave Arduino. Works :slight_smile: