LED Circuit (TinkerCad)

Introduction: LED Circuit (TinkerCad)

This project is for fun, and i made this myself. The point of this project is to change how much light is shining by a photoresistor. In this project, you will need 2 Resistors, a Photoresistor, a LED light, Arduino Uno R3, and wires. This project is on Tinkercad, so you will not have to buy these tools.

Step 1: Step 1: Build the Circuit

First, you will copy the picture above. You will get Arduino Uno R3 and will set it up somewhere on the screen. Next, you will get a LED light and Connect a Resistor to the Cathode on the LED. Then, you will set up a wire that is connected to the Resistor on the LED, and connect it to the GND on the AUR3 (Arduino Uno R3). You will do the same for the Anode, and will connect the wire from it to the D9 slot on the AUR3. On the next step, you will add a photoresistor and add another resistor, and then connect that to Terminal 1 on the photoresistor. Next, you will connect the resistor to the GND with a wire, which is found on AUR3. On the last step of building it, you will connect the A0 on the AUR3, and connect it to terminal 1, found on the photoresistor. Last, you will connect a wire from 5v, and connect it to terminal 2 on the photoresistor.

Step 2: Step 2: Code With Blocks

Click on the Variables category in the code editor.

To store the resistance value of the photoresistor, create a variable named "sensorValue". Drag out a "set" block. We'll store the state of our photoresistor in the variable sensorValue. Click on the Input category and drag out an "analog read pin" block, and place it into the "set" block after the word "to" Since our potentiometer is connected to the Arduino on pin A0, change the dropdown to A0. Click the Output category and drag out a "print to serial monitor" block. Navigate to the Variables category and drag your variable sensorValue onto the "print to serial monitor" block, and make sure the dropdown is set to print with a new line. Optionally start the simulation and open the serial monitor to verify readings are coming in and changing when you adjust the sensor. Analog input values range from 0-1023. Since we want to write to the LED with a number between 0 (off) and 255 (full brightness), we'll use the "map" block to do some cross-multiplication for us. Navigate to the Math category and drag out a "map" block. In the first slot, drag in a sensorValue variable block, then set the range from 0 to 255. Back in the Output category, drag out an analog "set pin" block, which by default says "set pin 3 to 0." Adjust it to set pin 9. Drag the map block you made earlier into the "set pin" block's "to" field to write the adjusted number to the LED pin using PWM. Click the Control category and drag out a wait block, and adjust it to delay the program for .1 seconds.

Step 3: Step 3: Try It!

Now that you’ve learned to read a photoresistor and map its output to control the brightness of an LED, you're ready to apply those and other skills you've learned so far. This project was not that hard, and only took me about 3 days to make. Thank you!

Be the First to Share


    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge
    • Halloween Contest

      Halloween Contest
    • Space Contest

      Space Contest