Light Intensity Lamp

Introduction: Light Intensity Lamp

Hey coders, today I will be teaching you how to create a lamp with a photo-resistor on TinkerCad. Let's get started!

Supplies

You will need:

* 1 Photo-resistor

* 1 Arduino Uno R3

* 1 Lightbulb

* 1 Relay SPDT (since the lightbulb takes 120 V and the Arduino only provides 5V)

* 1 Power Source

* 1 Breadboard

Step 1: Organization

The first thing you want to do is organize your materials like in the picture. This will make it easier when we have to wire everything together.

Step 2: Photoresistor

The first thing we will wire is the photo resistor. We connect the 5V pin to the positive terminal of the breadboard, add ground (making sure to add power/ground throughout the breadboard), and add the photo-resistor one pin-row above the ground. In between those, you wire the A0 pin to a 1000 ohm resistor, and connect it to positive.

Step 3: Power Supply, Relay, and Lightbulb

Next, we will wire up the power source, relay, and lightbulb with the Arduino. First, we should wire ground with the Arduino, and connecting the ends of each breadboard so power and ground goes all around the breadboard. Next, for the power supply, we connect ground to terminal 1 of the Relay, and add ground from terminal 8 of the Relay. The positive of the power supply goes to terminal 2 of the lightbulb, and the positive of the lightbulb goes to terminal 7 of the relay. Finally, we can connect digital pin 4 to terminal 5 of the Relay. With that, all the wiring/hardware is done, and we can move on to the coding of the Arduino!

Step 4: Coding in Arduino

The coding for this is in two parts; void setup and void loop. The setup, as it says, setups pins and the loop loops a piece of code.

For void setup, we use pinMode to select a specific pin number, and choose whether it is input or output. In this case, pin A0 is input, and pin 4 for output. Serial.begin starts the serial monitor for the photo-resistor. With that, we can start on the void loop.

For void loop, we write Serial.println(analogRead(A1)); to print the data of the photo-resistor and the serial monitor. We write an if statement that, if the photo-resistor gives numbers above 500 (or a dim light) that it would turn off the lightbulb, and turn it on if it was not dim. And just like that, the code is done and the circuit works!

Thank you for reading this tutorial! I hope you enjoyed!

Be the First to Share

    Recommendations

    • Space Contest

      Space Contest
    • Plastic Challenge

      Plastic Challenge
    • Organization Contest

      Organization Contest

    Comments