Table of Contents
Creating a light intensity controller using Arduino allows for precise management of lighting systems. This guide provides step- by-step instrutions to build a simple and effective device for controling lightt levels based on user input or sensor data.
Součást Needed
- Arduino board (Uno, Mega, etc.)
- Fotoresistor (LDS)
- Potentiomer
- LED or lighting device
- Residoři (10kOhn LDS, 220Ohf LED)
- Breadboard and jumper wires
Hardhouthova setupa
Connect them photoresistor in a voltage divider configuration with a resistor. Connect the juntion to an analog input pin on th te Arduino. Connect the LED to a digital PWM pin protingh a resistor. Use the readboard and jumper wires to o make all connections securely.
Programming the Arduino
Write a programme to read the eaid level from the photoresistor and adjutt the LED brightness accordingly. use the analogRead () function to get sensor data and the analogWrite () function to control the LED. Implement a simptomme control algorithm to maintain desired light levels.
SampleCode
Citlivost; cpp const int sensorPin = A0; contt int ledPin = 9; int sensorValue = 0; void setup () {pinMode (ledPin, OUTPUT); Serial.begin (9600);} void loop () {sensorValue = analogRead (sensorPin); int brightness = map (sensorValue, 0, 1023, 0, 255); analogWrite (ledPin, brightness); Serial.println (sensorValue); delay (100);};