Need help about rx tx communication between two arduinos

Hello everyone, I have an arduino uno and a micro and trying to make communication between them by using rx tx. However i have a trouble. My uno reads an analog data and sends it via tx leg. I can see the datas via serial monitor but i cannot receive it from arduino micro. The tx leg of uno is connected to the rx leg of micro. When i disconnect the uno from my computer (power is still on). it stops sending data. tx led does not emit light anymore. I believe it only communicates with the computer but not with the arduino micro. Can you help me with that problem? Thank you. My codes are below.

Arduino Uno's code(tx code)

int pot=0;
int a;
void setup()
{
  pinMode(pot, INPUT);
  Serial.begin(9600);
}
void loop()
{
  a=map(analogRead(pot),0,1023,0,255);  
  Serial.println(a);
  delay(1000);
}

Arduino Micro's code (rx code)

int a;
void setup()
{
  Serial.begin(9600);
}
void loop()
{
  if(Serial.available())
  {
    a=map(Serial.read(),0,255,0,1023);  
    Serial.println(a);
    delay(1000);
  }
}

Is ground connected between the 2 devices?

Tx side - may need to use Serial.write instead of Serial.print.

Rx side:
if(Serial.available()>1) // two bytes are coming over, 0x000000XX and 0xXXXXXXXX
  {
    alow = Serial.read();  // maybe swap these two so placement is correct
    ahigh = Serial.read();
    a = (ahigh<<8) | alow;
    Serial.println(a, HEX); // check high/low positioning
    // do your mapping stuff, print again to make sure it is correct
    delay(1000);
  }

Ah - you had already reduced it to 8 bits. In that case, just add the missing a = Serial.read(); on the Rx side.

i have tried them but rx side still does not recieve anything and rx led does not emit light. Everything on the board is common grounded. when i remove the usb cable of uno it's tx led stops working it stops sending data. Maybe is there any code that needed to be written in the setup so rx will recieve data

Describe your setup better. The USB from PC goes thru a USB/Serial chip into the RX/TX lines. You are connecting those same lines to a 2nd Arduino?

Here is a lousy scemetic of it.

When i remove the USB1 arduino uno(tx) stops sending data. However it should send to arduino micro(rx)

So what i want to do is read the analog data with UNO send it to MICRO via tx. Recieve it and read it with MICRO's Serial Monitor.

I think I am missing a major step but i just started yesterday, I was using Microchip's PIC. Still trying to figure out arduino.

Try powering via the barrel jack vs the USB, stop the interference on the Rx/Tx pins.

It does not send anything if usb cable is not connected to computer even the arduino is powered. By the way thank you for trying to help.

You have Rx connected to Rx it looks like? Need Tx of Uno to Rx of Micro.

my drawing is wrong sorry about that it is tx connected to rx. still couldn't figure it out. Any help is appreciated.

Make the delay 10 instead of 1000. Not going to see much LED action with just 1 byte one times a second.

Below is some servo/pot test code (you don’t need servos to test). check the output using the serial monitor. If yu can see the output, then you could add a delimiter prior to transmitting to make the data reception easier.

//zoomkat dual pot/servo test 12-29-12
//view output using the serial monitor

#include <Servo.h> 
Servo myservo1;
Servo myservo2;

int potpin1 = 0;  //analog input pin A0
int potpin2 = 1;

int newval1, oldval1;
int newval2, oldval2;

void setup() 
{
  Serial.begin(9600);  
  myservo1.attach(2);  
  myservo2.attach(3);
  Serial.println("testing dual pot servo");  
}

void loop() 
{ 
  newval1 = analogRead(potpin1);           
  newval1 = map(newval1, 0, 1023, 0, 179); 
  if (newval1 < (oldval1-2) || newval1 > (oldval1+2)){  
    myservo1.write(newval1);
    Serial.print("1- ");
    Serial.println(newval1);
    oldval1=newval1;
  }

  newval2 = analogRead(potpin2);
  newval2 = map(newval2, 0, 1023, 0, 179);
  if (newval2 < (oldval2-2) || newval2 > (oldval2+2)){  
    myservo2.write(newval2);
    Serial.print("2- ");    
    Serial.println(newval2);
    oldval2=newval2;
  }
  delay(50);
}