Lighting Loop or Disco

Github

Concept

I was initially thinking of making a a lamp which turns on in dark and can be manually turned on. But that seemed very boring. Then I thought that why don’t I use a light from one LED and use it as an input to for the LDR which can ultimately effect a second LED. While thinking about this, I thought that I can just create a switch like that using code. Along the lines, It came to me what I can do is make the light light fluctuating by making it fade in and out. So the LDR reading will change within a range and I can make the second LED a blink. This reminded me a party or disco lights where  different lights turn on and off at different rates.

Work

Both circuits were relatively simple as we did in the class, and the connection between them was through the code. To add more to it I used INPUT_PULLUP instead of a resistor. I had a conversation with GPT about this. It took me some time to get a grasp of regarding how it work. The next was putting the led close to the LDR. Now this was a bit tiring because the LDR was also detecting the room light. So I couldn’t have a fixed range, and the code needs to be updated if the location changes and new light in the room is introduced. I would regard this as the most challenging part.

On the other hand the part I am most proud of is dealing with multiple kinds of input. I was indeed relieving when my design did not require mapping of analog inputs and outputs. Initially I thought that I had to deal with all these multiple inputs but with just few lines of code, I was able to accomplish what I had in mind without nest if and loop blocks.

Sketch

 

Working Demo

 

Leave a Reply