Issue in checking functionality of UART

We are doing a project on Metaboard (USB based prototyping board for Atmel's AVR microcontrollers. It is designed to be mostly compatible with Arduino).

We are using Atmega8 microcontroller and CH340g to create a com port.
To test the UART functionality we wrote the following code:

int led = 3; \i have a led on pin 5 of M8(which is pin3 on arduino ng /w atmega8)
int value = 0;

void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);

}

void loop() {

if(Serial.available()>0){
value = Serial.read();
delay(5);

if (value == '1') {
digitalWrite(led, HIGH);
Serial.print("LED is ON");
}

if (value == '0') {
digitalWrite(led, LOW);
Serial.print("LED is OFF");
}
}
}

The code is not showing any error.
We have selected "Arduino NG with atmega8" board in arduino IDE.
When we send '1' via serial monitor the LED should glow but it's not glowing.
The code works fine when flashed on arduino Uno.
We are not able to understand why?

We are using Atmega8 microcontroller and CH340g to create a com port.

What does that have to do with the Metaboard?

Please post a hand drawn (not Fritzing) wiring diagram and explain.

I have attached the schematic of our board.

We have connected CH340G at Rx and Tx of Atmega8 for serial communication.
Now, when we are flashing the above mentioned program on the board we are not getting the output.
According to the code when we send '1' through serial monitor the LED should glow,which is not happening and we are not able to understand why.

Sorry, but what you have posted so far makes no sense at all.

The ATmega8 is not shown on your schematic. Do you have any code running on it?

If so, what is that code supposed to do?

In our project we have used atmega8 in place of atmega168.
For testing the functionality of CH340 we have flashed the following code:

int led = 3; \i have a led on pin 5 of M8(which is pin3 on arduino ng /w atmega8)
int value = 0;

void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);

}

void loop() {

if(Serial.available()>0){
value = Serial.read();
delay(5);

if (value == '1') {
digitalWrite(led, HIGH);
Serial.print("LED is ON");
}

if (value == '0') {
digitalWrite(led, LOW);
Serial.print("LED is OFF");
}
}
}

According to the code when we send '1' from PC, the board should glow the LED.
and when we send '0' the LED should be off.

Why do you expect the ATmega8 to work in place of the ATmega168?

swetaprasad:
According to the code when we send '1' from PC, the board should glow the LED.
and when we send '0' the LED should be off.

First of all: do go and read the sticky so at least you know the info we need and how to properly post code.

Then, what did you do to debug? The obvious steps would be verify Serial comms, verify soldering joints, verify pin number:

  1. See what comes back on the Serial monitor (you're printing things). If nothing, your Serial communication fails somewhere.
  2. If you get the response: see that your solder links are OK and the LED the correct way around and connected to the correct pin.
  3. Still nothing? Upload Blink with the pin you think it is. You should see your LED blink.
  4. No blink? Change Blink to blink EVERY output pin your processor has. Now you should definitely see your LED blink. Start reducing numbers until you find the pin your LED is really connected to.
  5. Still nothing? Make sure that LED is even in working order...

Note how I never even mentioned part numbers here? That's because it's irrelevant for this strategy. You don't seem to even know what you're doing, you don't seem to know which parts work and which parts don't. Figure that out first.