# Problem with generic arduino uno

**URL:** <https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880>\
**Category:** General Guidance\
**Created:** [November 23, 2024, 1:51am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880 "2024-11-23T01:51:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcusgollub](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/marcusgollub/32/1098565_2.png) [@marcusgollub](https://forum.arduino.cc/u/marcusgollub)\
**Post date:** [November 23, 2024, 1:51am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/1 "2024-11-23T01:51:18Z")

</div>

Hello, today I tried to make a light sensor with the generic arduino, I try to upload the code and it doesn't go, but for the project in tinkercad, it works normally, and when I disconnected the gnd wire, the red led lit up, and the yellow one slightly, but the green one didn't light up, and when I didn't disconnect it completely, both of them lit up very strongly, and it only worked on the gnd input of the analog part, on the power part it didn't work. if anyone can help me I appreciate it.

```arduino
int valor=0;  
int led1=13; 
int led2=12;
int led3=11;
 
 
void setup(){
  Serial.begin(9600);      
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
}
 
 
void loop(){
  
  valor = analogRead(A0);     
  Serial.println(valor);      
  
 if (valor < 600){            
    digitalWrite(led1,HIGH);  
    digitalWrite(led2,LOW);  
    digitalWrite(led3,LOW);   
  }
 if (valor >= 600 && valor <= 900){
    digitalWrite(led1,LOW);   
    digitalWrite(led2,HIGH);  
    digitalWrite(led3,LOW);   
  }
 if (valor >= 900){           
    digitalWrite(led1,LOW);   
    digitalWrite(led2,LOW);   
    digitalWrite(led3,HIGH);  
  }
  delay(200);     
}

```

---

<div class="post-metadata">

**Author:** ![mancera1979](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mancera1979/32/732001_2.png) [@mancera1979](https://forum.arduino.cc/u/mancera1979)\
**Post date:** [November 23, 2024, 2:00am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/2 "2024-11-23T02:00:35Z")

</div>

> [@marcusgollub](#):
>
> when I disconnected the gnd wire

We need to see your circuit. Please upload a picture of a diagram. Drawn by hand is Ok

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [November 23, 2024, 2:02am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/3 "2024-11-23T02:02:03Z")

</div>

> [@marcusgollub](#):
>
> `valor = analogRead(A0);`

What is connected to A0?

---

<div class="post-metadata">

**Author:** ![marcusgollub](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/marcusgollub/32/1098565_2.png) [@marcusgollub](https://forum.arduino.cc/u/marcusgollub)\
**Post date:** [November 23, 2024, 2:05am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/5 "2024-11-23T02:05:27Z")

</div>

![PXL_20241122_230449967](https://europe1.discourse-cdn.com/arduino/original/4X/c/0/e/c0e41b9a8f885fca4277b65c3c2ff8ab158380b8.jpeg)

---

<div class="post-metadata">

**Author:** ![marcusgollub](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/marcusgollub/32/1098565_2.png) [@marcusgollub](https://forum.arduino.cc/u/marcusgollub)\
**Post date:** [November 23, 2024, 2:05am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/6 "2024-11-23T02:05:57Z")

</div>

the ldr sensor

---

<div class="post-metadata">

**Author:** ![mancera1979](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mancera1979/32/732001_2.png) [@mancera1979](https://forum.arduino.cc/u/mancera1979)\
**Post date:** [November 23, 2024, 2:12am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/7 "2024-11-23T02:12:51Z")

</div>

> [@marcusgollub](#):
>
> `Serial.println(valor); `

What range of values are you getting in the monitor?

---

<div class="post-metadata">

**Author:** ![marcusgollub](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/marcusgollub/32/1098565_2.png) [@marcusgollub](https://forum.arduino.cc/u/marcusgollub)\
**Post date:** [November 23, 2024, 2:16am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/8 "2024-11-23T02:16:07Z")

</div>

> [@mancera1979](#):
>
> What range of values are you getting in the monitor?

what do you mean? I'm a beginner with arduino

---

<div class="post-metadata">

**Author:** ![bluejets](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bluejets/32/1013044_2.png) [@bluejets](https://forum.arduino.cc/u/bluejets)\
**Post date:** [November 23, 2024, 2:18am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/9 "2024-11-23T02:18:33Z")

</div>

A picture of your pc monitor is not necessarily how the hardware is connected in front of you.

---

<div class="post-metadata">

**Author:** ![marcusgollub](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/marcusgollub/32/1098565_2.png) [@marcusgollub](https://forum.arduino.cc/u/marcusgollub)\
**Post date:** [November 23, 2024, 2:23am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/10 "2024-11-23T02:23:25Z")

</div>

ok, is that the angle of the hardware photo is a bit bad, but it's ok

 ![PXL_20241122_232155959](https://europe1.discourse-cdn.com/arduino/original/4X/8/e/1/8e1b201c9431c6c89cd8fb4e961743160a964de2.jpeg)  
 ![PXL_20241122_232200883](https://europe1.discourse-cdn.com/arduino/original/4X/b/7/c/b7cb37274efe941cb85f70a953aaada9ffe45d8a.jpeg)  
 ![PXL_20241122_232206383](https://europe1.discourse-cdn.com/arduino/original/4X/7/0/7/707d01fa28df28feb9fcfcca3de46ac0e9a4c661.jpeg)

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [November 23, 2024, 2:30am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/11 "2024-11-23T02:30:53Z")

</div>

> [@marcusgollub](#):
>
> what do you mean? I'm a beginner with arduino

What numbers does Serial.println(valor); show? Did you try shining a bright light on the LDR?  
Try these numbers:

```arduino
int valor=0;  
int led1=13; 
int led2=12;
int led3=11;
 
 
void setup(){
  Serial.begin(9600);      
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
}
 
 
void loop(){
  
  valor = analogRead(A0);     
  Serial.println(valor);      
  
 if (valor < 200){            
    digitalWrite(led1,HIGH);  
    digitalWrite(led2,LOW);  
    digitalWrite(led3,LOW);   
  }
 else if (valor < 700){
    digitalWrite(led1,LOW);   
    digitalWrite(led2,HIGH);  
    digitalWrite(led3,LOW);   
  }
 else{           
    digitalWrite(led1,LOW);   
    digitalWrite(led2,LOW);   
    digitalWrite(led3,HIGH);  
  }
  delay(200);     
}
```

```arduino

```

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [November 23, 2024, 2:37am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/12 "2024-11-23T02:37:51Z")

</div>

Looks like you have a 220Ω resistor on the LDR instead of 10K.  
I hate those blue resistors. 😬 Can't tell red from orange from brown.

---

<div class="post-metadata">

**Author:** ![marcusgollub](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/marcusgollub/32/1098565_2.png) [@marcusgollub](https://forum.arduino.cc/u/marcusgollub)\
**Post date:** [November 23, 2024, 2:40am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/13 "2024-11-23T02:40:28Z")

</div>

nothing happens when I put on a bright light

---

<div class="post-metadata">

**Author:** ![marcusgollub](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/marcusgollub/32/1098565_2.png) [@marcusgollub](https://forum.arduino.cc/u/marcusgollub)\
**Post date:** [November 23, 2024, 2:44am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/14 "2024-11-23T02:44:17Z")

</div>

no, it's 10k, it's marked on the packaging, and I replaced it with the same one

---

<div class="post-metadata">

**Author:** ![marcusgollub](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/marcusgollub/32/1098565_2.png) [@marcusgollub](https://forum.arduino.cc/u/marcusgollub)\
**Post date:** [November 23, 2024, 2:45am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/15 "2024-11-23T02:45:31Z")

</div>

they're really bad

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [November 23, 2024, 2:50am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/16 "2024-11-23T02:50:35Z")

</div>

> [@marcusgollub](#):
>
> what do you mean?

Do you have the serial monitor window open?

Is it set to 9600?

Are numbers spilling out as you change the light shining on the LDR?

That's what @mancera1979 meant - the sketch is telling you what the LDR and _analogRead_() are seeing, which will tell you why it is working or not.

a7

---

<div class="post-metadata">

**Author:** ![marcusgollub](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/marcusgollub/32/1098565_2.png) [@marcusgollub](https://forum.arduino.cc/u/marcusgollub)\
**Post date:** [November 23, 2024, 2:50am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/17 "2024-11-23T02:50:54Z")

</div>

could it be a power problem? it's only connected to the pc's usb

---

<div class="post-metadata">

**Author:** ![marcusgollub](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/marcusgollub/32/1098565_2.png) [@marcusgollub](https://forum.arduino.cc/u/marcusgollub)\
**Post date:** [November 23, 2024, 2:54am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/18 "2024-11-23T02:54:31Z")

</div>

when the light gets closer they get bigger

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [November 23, 2024, 2:54am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/19 "2024-11-23T02:54:38Z")

</div>

Should be OK with 220Ω for the LEDs, are you sure they are connected the right way (polarity)?

---

<div class="post-metadata">

**Author:** ![marcusgollub](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/marcusgollub/32/1098565_2.png) [@marcusgollub](https://forum.arduino.cc/u/marcusgollub)\
**Post date:** [November 23, 2024, 2:57am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/20 "2024-11-23T02:57:19Z")

</div>

yes, the resistors are on the positive side of the led

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [November 23, 2024, 2:58am UTC](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880/21 "2024-11-23T02:58:37Z")

</div>

> [@marcusgollub](#):
>
> when the light gets closer they get bigger

Now tell us how small they get and how big they get.

a7

[Next page](https://forum.arduino.cc/t/problem-with-generic-arduino-uno/1324880.md?page=2)
