My board is weird?

Hi everyone, I got a problem.
My UNO didn’t work in many way(today that mean that was fine in the last two day).
1.It doesn’t read analog value (A0 - A5). It was fine in the last five days.
2.It doesn’t respond serial command - I write a program like, led will open when I sent ‘o’ and close when I sent ‘c’.
But it will work without serial command. Like in the following program.
//<>
void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH); delay(5000);
digitalWrite(13, LOW); delay(5000);
}
//<

//<
void setup()
{ pinMode(9, OUTPUT);
Serial.begin(9600);
}
void loop()
{while(Serial.available()<1)
{
int a=Serial.read();
if (a==‘n’)
digitalWrite(9, HIGH);
else if(a==‘b’)
digitalWrite(9, LOW);
else
Serial.println(“no one”);
}
}
//<>
Is my UNO is dead?

=(

void loop()
    {
    while(Serial.available()<1)   ////// While the number of available bytes is 0...
        {
        int a=Serial.read();     /////////// ... read the first available byte?!?!?

Hi johnwasser,
I have tested it, it doesn’t work.
Is there any way of checking my board is dead or not.
Thanks

Try the working program again. If it works again then it is the sketch that was not working. There is a mistake in your code which I pointed out. Perhaps that mistake is preventing your sketch from doing what you thought you told it to do.

Hi johnwasser, I got another problem.
Analog pin is working, according to the following sketch
<>
int sensor;
void setup()
{ Serial.begin(9600);
pinMode(9, OUTPUT);

}

void loop()
{ sensor=analogRead(1); //Light Dependent Resistor
sensor=map(sensor,0,1023,0,10);
delay(1000);

Serial.println(sensor);
if (sensor<=2)
{
digitalWrite(9, HIGH);

}
else { digitalWrite(9, LOW);}

}

The led is shiny bright when I cover the LDR with my hand(serial monitor show ‘2’). But I got a problem with using serial command, as below.

int lead=9;
void setup()
{
Serial.begin(9600);
}
void loop()
{
if (Serial.available() >0)
{
char c=Serial.read();
if (c==‘o’)
{
digitalWrite(lead, HIGH);
}
else if(c==‘c’)
{
digitalWrite(lead, LOW);
}
else Serial.println(“Others”);
}
}

When I sent other character not ‘o’ and ‘c’, the serial monitor respond as I desired(“Others”).
When I sent ‘o’, the lead is not absolutely dead, I notice little light that is not bright like in the working program.
That means, the lead in the same pin is bright that is trigger by UNO’s IO (in my sketch LDR) and not(not bright like previous) bright that is trigger by serial command.
Help me.

One way to test the integrity of microcontroller is to burn the bootloader again. It works for me :slight_smile:

In http://arduino.cc/en/Tutorial/ArduinoToBreadboard, you will learn how to do it.

Best regards,

Willian Paixao.

moorejohn90:

int lead=9;

void setup()
{
Serial.begin(9600);
}
void loop()
{
if (Serial.available() >0)
{
char c=Serial.read();
if (c==‘o’)
{
digitalWrite(lead, HIGH);
}
else if(c==‘c’)
{
digitalWrite(lead, LOW);
}
else Serial.println(“Others”);
}
}

You forgot pinMode(9, OUTPUT);

Hi Mr.johnwasser, I am very thanks you for your help. Yep I forgot of declaring pinMode(Led, OUTPUT). I can solve my problem after adding that. And thanks to willianpaixao for giving me giving advice. With best wishes, MJohn