Pages: [1]   Go Down
Author Topic: My UNO broken? Can not on and off LED  (Read 195 times)
0 Members and 1 Guest are viewing this topic.
universe
Offline Offline
Sr. Member
****
Karma: 0
Posts: 258
I'm enjoying my Life
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I suspect my Arduino UNO broken, but I do not it is true broken or any else. My pin 13 (which contain build in led) always ON
And after I upload this code:
Code:
void setup()
{
 Serial.begin(9600);
 digitalWrite (13,LOW);
}



void loop()
{
 while (Serial.available()==0);

int val = Serial.read () - '0';

if (val ==1)
{
  Serial.println("Led is On");
  digitalWrite(13,HIGH);
}
else if (val == 0)
{
 Serial.println("Led is off");
 digitalWrite(13,LOW);
}
else
{
 Serial.println("Invalid");
}
}

then I open serial monitor,
i input 0, then it displays "Led is off", but the led is not turned off

WHAT HAPPEN TO MY ARDUINO?? ANY HELP PLEASE...
Logged

Offline Offline
Edison Member
*
Karma: 56
Posts: 2143
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need:
pinMode(13, OUTPUT); 
Logged

UK
Offline Offline
Shannon Member
****
Karma: 183
Posts: 11142
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I suspect my Arduino UNO broken, but I do not it is true broken or any else.

The bug in your sketch has already been pointed out.

In future, if you are concerned that you may have broken your Arduino, take off any hardware you may have connected to it and upload an example sketch such as 'blink'.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: