Introduction: Light Sensor With Arduino
This is an example of a light sensor DIY with Arduino.
Idea is available from: https://www.instructables.com/id/Light-Sensor-Phot...
I used the circuit and codes from the source and make some changes in both codes, circuit, and appearance.
Codes: The source below provides code that the LED should be brighter when the environment is brighter and darker when the environment when darker. I change it to when the environment is brighter, the LED is darker, when the environment is darker, the LED will be brighter.
Circuit: Add one more LED on the circuit.
Appearance: Add a box that covers the whole Arduino to make it prettier.
- 2 LED lights (the project below uses one blue and one red)
- 8 lines (wires)
- 2 yellow resisters
- 1 blue resister
- 1 light sensor
- 1 Arduino
- 1 breadboard
- 1 half-transparent box
- 1 cable (connecting line for Arduino and computer)
Step 1: Prepare Materials
Prepare all the materials mentioned in "supplies."
Step 2: Build the Circuit
- Connect positive charge with 5V and negative charge with GND.
- Add two LEDs on the breadboard.
Connect one leg of the yellow resister with the shorter leg of the LED (on the same line) and another leg on a negative charge. As for the longer leg of the LED, connect it with a wire and on digital 9 or 6 (optional for which digital, but the code provided in the next step would use these two).
*Repeat twice for both LEDs*
- Insert the light sensor in wires so it is longer which will advantage in later
Connect one leg with analog In 0, or A0 (optional for which analog, but the code provided in the next step would use this). With the same leg, connect it with the blue resister which another leg of the blue resister will connect with negative charge. Another leg of the light sensor will connect with a wire which will connect to positive charge.
在黃色的電阻一隻腳連接LED比較短的腿，另一隻腳連接負極。在LED燈比較長的腿連結一條電線又會連接到digital 9 或 6 (可以改變，但是之後給的程式碼會使用這兩個）
連接一個腳與analog 0 (可以改變，但是之後給的程式碼會使用這一個）。同一個腳連接藍色電阻，藍色電阻又會連接到負極。另一個光敏感測器的腳連接到一個電線然後電線又連接到正極。
Step 3: Upload the Code
Step 4: Test
After building the circuit correctly and adding the code, test the project by uploading the code onto Arduino. If it doesn't work, check your circuit and code if there is something connect wrong (things to check such as if the code's analog or digital work with the circuit).
完成電路和程式碼後，上傳程式碼檢查是否成功。如果沒有成功，檢查你的電路和程式碼是否有錯誤（例如程式碼的analog 和 digital 和電路有沒有不同）。
Step 5: Decorate
Cover the whole breadboard and Arduino with the half-transparent box. Remember to put the light sensor out of the box.
Step 6: FINISHED!!
View the video and see if your project looks the same.
*The project is set on purpose that the darker the outside is, the lighter the LED will be. Same on the opposite, the lighter the outside is, the darker the LED will be.