I just want to monitor an input from various remote controls, if their PIN matches it must display the 15 bytes of data.
It works fine for the first message in, it SerialPrints the PIN and 15 bytes, then nothing..
Must I flush the incoming buffer ? or is this another brain fart / senior moment ?
#include <NewSoftSerial.h>
#define RXPIN 14 //
#define TXPIN 15 //
#define SIMBAUD 9600
int n = 1;
int PIN = 40;
NewSoftSerial SIM(RXPIN, TXPIN);
int tile [15];
void setup () {
SIM.begin(SIMBAUD);
Serial.begin(9600); }
//***************************************************************************************
void loop() {
if (SIM.available() > 0) { // get incoming byte:
Serial.println(" something available ");
int indata = SIM.read ();
if (indata == PIN || indata == 39){ Serial.println(indata);
for (int n = 1; n <=15; n++ ){
tile [n] = SIM.read ();
Serial.println(tile [n]);
} } } // end of is serial avail
}// end of
Thanks James, it works in the main receivers of the project, but I tried as below and its the same ?
#include <NewSoftSerial.h>
#define RXPIN 14 //
#define TXPIN 15 //
#define SIMBAUD 9600
int n = 1;
int PIN = 40;
NewSoftSerial SIM(RXPIN, TXPIN);
int tile [15];
void setup () {
SIM.begin(SIMBAUD);
Serial.begin(9600); }
//***************************************************************************************
void loop() {
if (SIM.available() > 0) { // get incoming byte:
Serial.println(" something available ");
for (int n = 0; n <=15; n++ ){
tile [n] = SIM.read ();
Serial.println(tile [n]);
}
} // end of is serial avail
}// end of loop