NewSoftSerial (HELP)


hello all,

your in problem below wellcome.

need use 2 tx outputs, 1 setup gps , other 1 send lat., long., etc system (two way radio control receiver). made several attempts without success, can't  any signal @ tx pin3 code below (it has lot of patches test input, because, wasn't able read inputs sentence. had setup baudrate 4800 in order sentence without errors):


code: [select]

#include <newsoftserial.h>

newsoftserial gps1(2, 3);
newsoftserial gps(0, 1);
string chkstr = string(5);
string datastr = string(65);
string returnstr = string(12);

char chkbyte;
char inbyte;
int = 10;
int page = 1;

void setup() {

 pinmode(0, input);
 pinmode(1, output);
 pinmode(2, input);
 pinmode(3, output);
 lcd.begin(dog_lcd_m163,0x28);
 lcd.setcursor(0, 0);
 lcd.print("--arduino  gps--");
 lcd.setcursor(0, 1);
 lcd.print("------v2.1------");
 delay(2000);
 gps1.begin(38400);
 serial.begin(38400);
 gps1.read();
 serial.print("$pmtk251,4800*14\r\n");  
 gps.begin(4800);
 serial.begin(115200);
 delay(200);

 gps.read();

}

void loop() {
  chkstr = '\0';
// if (gps.available() > 0) {
 //  chkbyte = gps.read();
   //while (chkbyte > 0) {
     if (i > 0) {
       if (gps.available() > 0) {
         inbyte = gps.read();
         //chkstr.concat(inbyte);
           serial.print(inbyte);
         i--;
       }
       else {
         waitforbyte();
       }
     }
     else {
       i = 10;
     //  break;
     }
     while (chkstr.equals("gprmc")) {
       if (gps.available() > 0) {
             inbyte = gps.read();
           datastr.concat(inbyte);
               //serial.print(inbyte);
         }
        else {
         waitforbyte();
       }
       }
   }
// }
//}
void waitforbyte() {
 while (true) {
   if (gps.available() > 0) {
     break;
   }
   else {
     continue;
   }
 }
}


considering didn't result sketch (kind of) above, tried example below, didn't output @ tx pin3 , tx pin5. output @ tx pin1, in both cases . appreciated.

thanks , regards,
manuel

         
code: [select]
 #include <newsoftserial.h>

newsoftserial nss(2, 3);
newsoftserial nss2(4, 5);
     
void setup()
{
 nss2.begin(19200);
 nss.begin(19200);
 serial.begin(115200);
}
     
void loop()
{
// every 10 seconds switch
// 1 serial gps device other
if ((millis() / 10000) % 2 == 0)
 {
   if (nss.available())
   {
     serial.print(nss.read(), byte);
   }
}

 else
 {
   if (nss2.available())
  {
     serial.print(nss2.read(), byte);
  }
 }
}  

code: [select]
 pinmode(0, input);
 pinmode(1, output);

pins 0 , 1 serial class pins. should not setting mode these pins.

code: [select]
 gps1.read();
 gps.read();

what's for? if not capturing output, purpose of reading? it's reading book blindfold on.

quote
considering didn't result sketch (kind of) above, tried example below, didn't output @ tx pin3 , tx pin5. output @ tx pin1, in both cases .

where writing using gps or gps1. if don't write, how can expect data on tx pins classes?


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > NewSoftSerial (HELP)


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums