-->
Page 1 of 3

Has anyone got Serial.swap() to work?

PostPosted: Tue May 05, 2015 12:32 pm
by russmathis
The following code works ok. It should send "test" to the serial monitor every second.
void setup(){
Serial.begin(9600);
while(true){
Serial.println("test");
delay(1000);
}
}
void loop(){}

However, the folling code does not work, nothing is output to the serial monitor;
void setup(){
while(true){
Serial.println("test");
delay(1000);
Serial.swap(); //just testing if I can flip back and forth first
delay(1000); //maybe should not use delay? block interrupts?
Serial.swap();
}
void loop(){}

The goal is to collect input from an RFID device on pins 15 & 13 but if the above don't work
I suspect waiting for input on the swaped lines wont work either. Actually I tried already
and went back to this simple routine to test functionality with no success.

Anyone have any ideas?

One thought I'll try next is to delay without using delay(1000). Perhaps a while((millis()-startMillis)<1000)

Thanks.

Re: Has anyone got Serial.swap() to work?

PostPosted: Tue May 05, 2015 2:27 pm
by russmathis
I've tried the while ((millis()-lastMillis)<1000){}
and it does not work either.

Still looking for the answer here.
Any help would be appreciated.

Re: Has anyone got Serial.swap() to work?

PostPosted: Wed May 06, 2015 8:21 am
by Ribeiro Santos
Hi, which RFID model are you using?
By example, the RFID ID-12 has a pin (10) that can be used as interrupt to notify ESP8266 a new tag arrived.

Example with arduino.

Re: Has anyone got Serial.swap() to work?

PostPosted: Wed May 06, 2015 9:17 am
by ArnieO
russmathis wrote:Anyone have any ideas?

Stupid comment maybe, but I notice you are missing this in the code that is not working:
Serial.begin(9600);