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?

You might have damaged some inputs, try a new AVR chip in it. Make sure that you get one with the bootloader.

Is there any way of checking my board is dead or not, I live in Myanmar and it is hard to get new one (i bought from Thailand).

Thanks :mrgreen:

Have you checked to see if you can read those pins as digital inputs?

Hi Leon Heller, It is work(digitalRead).

Moore John

t looks as though you might have damaged the ADC inputs, then.

You may or may not have hardware problems, but that second program probably won’t work as desired. If Serial.available() is < 1, then there are no characters to read. I’d use:```
while (Serial.available() > 0) {…}

Use the Serial.Read example built into the Arduino IDE to eliminate the possibility of coding errors.

Just to check, you are trying to read the ANALOG IN pins yeah, not the digital ones? You say they were working a few days ago, but still…

Hi everyone, I got another problem.

Analog pin is work again, 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.

Moore John.

You should use Code tags to make your code readable - [ code ] [ /code ] round it (remove the spaces).

In the second sketch, you forgot to set the pin as an output. Therefore, instead of setting it high, you are turning on the pullup, which barely lets through enough current to light the LED.

/mike

Hi, Thanks you to leon_heller,n1ist,JChristensen and trialex.

Finally all of your help can solve my problem.

I forgot to add (pinMode(led,OUTPUT) and (while(Serial.available()<1) made the problem.

I am very glad and thanks to all of your help.

With best wishes,

Moore John.