Whats is wrong here? I am trying to make a code that combines LDR and RGB LED

#include <Adafruit_GFX.h>
#include <Adafruit_GrayOLED.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>

int redPin = 11;
int greenPin = 10;
int bluePin = 9;
const int ldrPin = A0;

void setup()
{

pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(ldrPin, INPUT);

}

void loop(){

int ldrStatus = analogRead(ldrPin);
if (ldrStatus <=300) {
setColor(255, 0, 0);
}
if (ldrStatus <=200) {
setColor(0, 255, 0);
}
if (ldrStatus <=100);{
setColor(0, 0, 255);
}
else {
setColor(255,255,255);
}
}

This one is not like the others.

Didn't the compiler complain about the else?

Also, study else if ()

And there is no setColor( ) function.

Welcome to the parté…
Now you’ve arrived, read up on posting questions, especially how to post code blocks.

Aside: Your post doesn’t actually tell us what you want your program to do, or what it does wrong.
Luckily the snippets you provided were extremely simple to diagnose.

If it was any more complex, you would have received a more vociferous greeting from the helpers !

Enjoy the group.. we really do like to help.

@gigihespanha, your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem :wink:

Well not for the LEDs anyways. It may be from one of the libraries included, to set the drawing color for subsequent graphics calls.

To make colors on you RGB LED you have to turn on the components you want, and turn off the ones you don’t. So

      digitalWrite(redPin , HIGH);
      digitalWrite(greenPin , HIGH);
      digitalWrite(bluePin, LOW);

would make it one of the 8 possible full on colors available if we doing no color, off.

HTH

a7