Go Down

Topic: Serial Not Working With External Power (Read 580 times) previous topic - next topic

DeuceBox

I have an Arduino Mega and have had no problems until I tried using an external power supply for the first time tonight. I'm simply trying to use a parallax RFID reader and my sketch works fine when the board is connected through USB, however, when connected to only an external power supply, the code seems to execute but the serial part does not work.

My Code:

Quote

int  val = 0;
char code[10];
int bytesread = 0;

void setup() {
pinMode(52,OUTPUT); //Enable/Disable RFID pin
pinMode(13,OUTPUT); //LED used to make sure the loop is running
digitalWrite(52, LOW); //Enable the RFID
Serial1.begin(2400); //Arduino Mega RX1 (Pin 19) connected to SOUT from RFID reader
}  


void loop() {

  digitalWrite(13, HIGH); //Blink the LED to show we're in the loop
  delay(100);
  digitalWrite(13, LOW);
  delay(100);
 
 if(Serial1.available() > 0) {          // if data available from reader
   if((val = Serial1.read()) == 10) {   // check for header
     bytesread = 0;
     while(bytesread<10) {              // read 10 digit code
       if( Serial1.available() > 0) {
         val = Serial1.read();
         if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading
           break;                       // stop reading
         }
         code[bytesread] = val;         // add the digit          
         bytesread++;                   // ready to read next digit  
       }
     }
     if(bytesread == 10) {              // if 10 digit read is complete
       digitalWrite(52, HIGH);          // Disable and re-enable after 2 seconds when a card has been read
       delay(2000);
       digitalWrite(52,LOW);
     }
     bytesread = 0;
          delay(500);                       // wait for a second
   }
 }
}


When connected through USB the pin13 light blinks as it should and when a card is held up, the parallax led goes from red to green for 2 seconds then changes back. Perfect.

When connected through an external power supply, the pin13 light blinks which means the sketch has made it into the loop, but nothing happens when I hold a card up to the RFID reader.

Any thoughts/suggestions would be greatly appreciated.

pluggy

Your external power supply isn't up to scratch ?
Have you tried another one ?
If its on the edge for smoothing or voltage, you can get unexpected problems.
http://pluggy.is-a-geek.com/index.html

DeuceBox

That was the problem, it was that simple. Thanks.

Go Up