LDR control LED-RGB & speaker

LDR control LED-RGB & speaker

We done the last arduino code wich was a bit more complex that the others. We make a RBG led to give different colors depending of the light that recives a LDR, and the reproduce a sound too

Apart from all the materials used for the other stuff, we now will use a RBG LED, a LDR resistor and a buzzer

For this, we've used the following code which I will explain how it works:

First we do the same as always. We will say to the code where is located everything.

Here we will just put lots of values depending of how we want to make the RBG LED color to change in every point of intensity of the LDR resistor, here in the photo there isn't everything

We create color, which will be a variable that will help in the "else if" structure used in the loop, that controls colour depending of the light intensity

We will connect everything to the chip similar to the scheme of below, and then run the code