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.
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);
}