RX ,TX pin not working when connected to 9V supply

I brought a new arduino mega for my serial communication project using two arduino and computer.
So when i uploaded the program and checked it through serial monitor the arduino was serial printing in the monitor.But when i provide 9v supply to arduino,it stopped serial transmitting(Tx led not blinking).I dont know what is going on!!

I'm sure nobody else does either, but that may simply be because your code is clearly a secret - as is the precise nature of the 9v power.

You will save everyone's time if you read and follow the guidelines for the use of the forum. See #7 & 11.

its nothing related with the code i think,thats why i didnt provide code.

#include <LiquidCrystal.h>
String text="";
int no=1001;

const int sensorIn = A1;
int mVperAmp = 66; // use 100 for 20A Module and 66 for 30A Module
double Amps;
double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;
double a1=0;
int m;// initialise variable m
float n;//initialise variable n
double kilos = 0;
int peakPower = 0;
int v;
int v1;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); //Assign LCD screen pins

void setup(){
lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear();
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print(“Running”);
pinMode(A0,INPUT); // set pin a0 as input pin
Serial.begin(9600);
Serial1.begin(9600);
}

void loop(){

Voltage = getVPP();
VRMS = (Voltage/2.0) 0.707; //
a1 = (VRMS * 1000)/mVperAmp;
AmpsRMS=a1/1.37;
Amps=AmpsRMS-0.14;
if(Amps<0)
{AmpsRMS=0;}
m=analogRead(A0);// read analog values from pin A0 across capacitor
n=(m
.317693059/1.4142);// converts analog value(x) into input ac supply value using this formula ( explained in working section)
v1=n-5;
if(v1<0)
{v=0;}
else{
v=n;}
int RMSpower=n*AmpsRMS;
if(RMSpower>peakPower)
{
peakPower=RMSpower;

}
delay(2000);
kilos=kilos+(RMSpower*(2.05/60/60/1000));
lcd.clear();
lcd.setCursor(0,0); // Displays all current data
lcd.print(AmpsRMS);
lcd.print(“A”);
lcd.setCursor(10,0);
lcd.print(v);
lcd.print(“V”);
lcd.setCursor(0,1);
lcd.print(kilos);
lcd.print(“kWh”);
lcd.setCursor(10,1);
lcd.print(RMSpower);
lcd.print(“W”);

text=text+no+","+v+","+AmpsRMS+","+kilos+":";
Serial.println(text);
sendAndroidValues();
text="";
delay(1000);

}

float getVPP()
{
float result;
int readValue; //value read from the sensor
int maxValue = 0; // store max value here
int minValue = 1024; // store min value here

uint32_t start_time = millis();
while((millis()-start_time) < 1000) //sample for 1 Sec
{
readValue = analogRead(sensorIn);
// see if you have a new maxValue
if (readValue > maxValue)
{
/record the maximum sensor value/
maxValue = readValue;
}
if (readValue < minValue)
{
/record the minimum sensor value/
minValue = readValue;
}
}

// Subtract min from max
result = ((maxValue - minValue) * 5.0)/1024.0;

return result;
}
void sendAndroidValues()
{
Serial1.println(text);
delay(10);
}

Please edit your post to add code tags.

Describe the 9V power source, and explain how you connected it.

So why did you ignore reply #2?
If you can not understand the instructions then it is sure you can not understand any answers you get given.
If you can't be bothered to read and understand the instructions why should anyone be bothered to help you?