Introduction
- In this article, I will explain how to control Light/Fan using Arduino Mega 2560. Light and fan will be controlled by the potentiometer.
- We can adjust the potentiometer and light and fan will be controlled by us.
Parts Of List
- Arduino Mega 2560
- Potentiometer
- LED
- Bread board
- Hookup wires
Potentiometer:
- It has three terminals.
- It has a sliding or rotating contact that forms an adjustable voltage divider.
- It acts as a variable resistor (or) rheostat.
Figure 1: potentiometer
Connection:
Step 1: Potentiometer to ArduinoMega2560
Step 2: Connection From LED To Arduino Mega 2560
Postive pin = 06
Negative pin = Gnd
Programming
- const byte POTENTIOMETER = 0;
- const byte CONTROL = 6;
- int reading;
- int value;
- void setup()
- {
- pinMode(CONTROL, OUTPUT);
- }
- void loop()
- {
- reading = analogRead(POTENTIOMETER);
- value = map(reading, 0, 1024, 0, 255);
- analogWrite(CONTROL, value);
- }
- Through this we can control Light /fan using potentiometer.
- If we adjust the potentiometer on the decreasing side the light brightness decreases.
- Also the fan speed also decreases.
- If we adjust the potentiometer on the increasing side the light brightness increases.
- Also the fan speed increased.
Output:

Figure 2: Output
Read more articles on Arduino:


Sr KarthigaPosted May 25, 2016, 4:23 AM EDT
thank you santhakumar sir
Sr KarthigaPosted May 25, 2016, 4:22 AM EDT
thank you vivek sir
Santhakumar MunuswamyPosted May 20, 2016, 10:34 PM EDT
Thank you for nice work
Vivek KumarPosted Apr 27, 2016, 5:30 AM EDT
Nice one
Sr KarthigaPosted Apr 21, 2016, 6:49 PM EDT
Thank you debasis sir
Sr KarthigaPosted Apr 21, 2016, 6:48 PM EDT
Thank you gowtham sir
Sr KarthigaPosted Apr 21, 2016, 6:48 PM EDT
Thank you Rahul Saxena sir
Sr KarthigaPosted Apr 21, 2016, 6:48 PM EDT
Thank you Shakti Singh Dulawat sir
Debasis SahaTOP 100Posted Apr 21, 2016, 9:30 AM EDT
Nice One..
Gowtham KTOP 100Posted Apr 21, 2016, 9:20 AM EDT
Good One, Thanks for sharing:)
Rahul Kumar SaxenaTOP 100Posted Apr 21, 2016, 5:10 AM EDT
Good one
Shakti Singh DulawatPosted Apr 21, 2016, 2:38 AM EDT
Simply awesome , Nice step and very well explain
Sr KarthigaPosted Apr 20, 2016, 6:57 PM EDT
thank you vignesh mani sir
Sr KarthigaPosted Apr 20, 2016, 6:57 PM EDT
which clg
Vignesh ManiTOP 100Posted Apr 20, 2016, 11:53 AM EDT
Nice
Tamilan SPosted Apr 20, 2016, 10:57 AM EDT
I also paavai