Dimming Light Bulb With Arduino

We recognize our top users by making them a Tindarian. Tindarians have access to secret & unreleased features. How does one become a Tindarian? We look for the most active & best members of the Tindie community, and invite them to join. There isn't a selection process or form to fill out. The only way to become a Tindarian is by being a nice & active member of the Tindie community! Electrical engineering student in Newfoundland, Canada. I enjoy bringing my ideas to life and understanding how things work. Designing circuits / product design is the field I would like to end up in after finishing my degree, whether that be consumer electronics, industrial, automotive, etc.Analog Voltage Reading Method The easiest way to measure a resistive sensor is to connect one end to Power and the other to a pull-down resistor to ground. Then the point between the fixed pulldown resistor and the variable photocell resistor is connected to the analog input of a microcontroller such as an Arduino (shown)
For this example I'm showing it with a 5V supply but note that you can use this with a 3.3v supply just as easily. In this configuration the analog voltage reading ranges from 0V (ground) to about 5V (or about the same as the power supply voltage). The way this works is that as the resistance of the photocell decreases, the total resistance of the photocell and the pulldown resistor decreases from over 600KΩ to 10KΩ. That means that the current flowing through both resistors increases which in turn causes the voltage across the fixed 10KΩ resistor to increase. Its quite a trick! LDR + R (Ω) Current thru LDR +R Dark overcast day / Bright room This table indicates the approximate analog voltage based on the sensor light/resistance w/a 5V supply and 10KΩ pulldown resistor. If you're planning to have the sensor in a bright area and use a 10KΩ pulldown, it will quickly saturate. That means that it will hit the 'ceiling' of 5V and not be able to differentiate between kinda bright and really bright.
In that case, you should replace the 10KΩ pulldown with a 1KΩ pulldown. Redbone Coonhound For Sale In ScIn that case, it will not be able to detect dark level differences as well but it will be able to detect bright light differences better. Boxer Puppies For Adoption In DenverThis is a tradeoff that you will have to decide upon!House For Sale Finch And Islington You can also use the "Axel Benz" formula by first measuring the minimum and maximum resistance value with the multimeter and then finding the resistor value with: Pull-Down-Resistor = squareroot(Rmin * Rmax), this will give you slightly better range calculations LDR + R (?) This table indicates the approximate analog voltage based on the sensor light/resistance w/a 5V supply and 1K pulldown resistor.
Note that our method does not provide linear voltage with respect to brightness! Also, each sensor will be different. As the light level increases, the analog voltage goes up even though the resistance goes down: Vo = Vcc ( R / (R + Photocell) ) That is, the voltage is proportional to the inverse of the photocell resistance which is, in turn, inversely proportional to light levels. Simple Demonstration of Use maybe spend some time reviewing the basics at the Arduino tutorial? Simple Code for Analog Light Measurements This code doesn't do any calculations, it just prints out what it interprets as the amount of light in a qualitative manner. For most projects, this is pretty much all thats needed!Reading Photocells Without Analog Pins Because photocells are basically resistors, its possible to use them even if you don't have any analog pins on your microcontroller (or if say you want to connect more than you have analog input pins). The way we do this is by taking advantage of a basic electronic property of resistors and capacitors.
It turns out that if you take a capacitor that is initially storing no voltage, and then connect it to power (like 5V) through a resistor, it will charge up to the power voltage slowly. The bigger the resistor, the slower it is. This capture from an oscilloscope shows whats happening on the digital pin (yellow). The blue line indicates when the sketch starts counting and when the couting is complete, about 1.2ms later. This is because the capacitor acts like a bucket and the resistor is like a thin pipe. To fill a bucket up with a very thin pipe takes enough time that you can figure out how wide the pipe is by timing how long it takes to fill the bucket up halfway.The goal of this project is to control the brightness of a light bulb with an IR remote control. The chips being used are the SIS-2 IR receiver/decoder and the AD8402 digital potentiometer. The SIS-2 is used in coordination with an IR receiver module to learn and respond to two different IR codes. The learned IR codes being used are those of the "channel up" and "channel down" buttons on a standard television remote.
The digital potentiometer was used to react to the button presses and adjust an ouput voltage, leading to the DC light bulb, accordingly. Pressing the "channel up" button would brigthen the light, while pressing the "channel down" button would dim it. The pin descriptions for the SIS-2 and the AD8402 can be found at these corresponding links. The SIS-2 chip first needed to learn the two buttons used. A video showing how this is done is in the next section. Once the buttons are learned, the chip is able to save that information in its nonvolatile memory, and does not need to be programmed again. Any time one of the learned IR codes is received from then on, one of the ouput pins will react accordingly. It was desired to set up a test circuit before linking the outputs of the IR decoder to the digital potentiometer through the Arduino. The test circuit is shown below and the corresponding code can be found here. In this circuit, the LEDs are lit according to the button presses.
Pressing the "channel up" button on the remote would move the lighting to the above LED, or back to the bottom LED if it had reached the top. The opposite was true for pressing the "channel down" button. A video demonstration can be seen in the next section. The next step was testing the digital potentiometer. A test circuit was set up with pushbuttons as the input commands: The code that goes along with this test circuit can be found here. In this circuit, push buttons were used to mimic the actions of the remote control. When setting Vss to ground and Vdd to 5 V, the output voltage could vary between about 10 mV and 4.9 V at steps of about 20 mV. A DC light bulb was connected to this output voltage and should have been able to brighten and dim according to this voltage. However, at the time, I was unaware that DC light bulbs do not have a resistance, like bulbs designed for the typical AC outlet. A video showing the monitor output of the program can be found in the next section.
I decided to go ahead and wire a circuit and code for the final toy design, despite not getting the test circuit for the digital potentiometer to work. The final circuit design is shown below: Here, the Arduino responds to the SIS-2 outputs by loading the digital potentiometer with a varying wiper value. The AD8402 identifies which of the two pots to output to, and computes the corresponding output voltage. It was during this set up that I found out about my problem with the DC light bulb. Because of this little fact, I had to modify my project so that LEDs would be dimmed instead of the light bulb. A demo of the final IR controlled dimmer can be seen in the next section. Programming the IR decoder and LED control demo Here, programming is done while the LEDs are scrolling downward uniformly. First, the pushbutton is pressed to indicate the chip is in learning mode. Each button needs to be pressed four times in succession for the chip to learn its IR code. Once this has been done, the LEDs stop scrolling and respond to the "channel up" and "channel down" button presses on the remote.
Screen output from digital potentiometer test Because the light could not be shown to brighten and dim in the digital potentiometer test circuit, serial output is shown on the screen. Buttons are being pressed when I say "up" or "down" in the video. The Arduino program recognizes this and increases or decreases the value of the digital potentiometer. This value, along with the address of the potentiometer (there are 2 on the chip) are sent to the Serial Data Input pin on the AD8402. Values on the screen show either UP or DOWN, the output POT value, and SENDING. Final demo of LED light dimmer 04/05 - Began research on SIS-2 IR receiver/decoder chip and IR protocol. 04/11 - Received SIS-2 chip. Got wrong IR receiver module. Looked into how Harrison and Robert interfaced with the chip for midterm. Began modifying their code to suit what I wanted to do with the chip. 04/12 - Looked into what I wanted to do with commands from IR receiver. Original idea was to recreate "Tin Can Alley" game by using remote control as a "gun" that would knock cans off of a platform when it was aimed at them.
04/13 - Looked into using a solenoid for the action of knocking cans off platform. Found it wouldn't provide the desired 'pop'. 04/15 - Received new IR receiver module to use with SIS-2. 04/18 - Decided to use SIS-2 in coordination with digital potentiometer to adjust the brightness of a light bulb. Ordered AD8402 digital potentiometer chip. Started wiring for testing the SIS-2 with LEDs. Was able to successfully program the chip to recognize two buttons from remote control. 04/20 - Debugging program to test SIS-2 with LEDs. Found that both outputs from the chip were sometimes going HIGH when either up or down was pressed on remote. Decided that a new remote was needed, as the one I was using was old and program seemed be fine otherwise. 04/22 - Researched how Matt and Derek used the chip for their midterm. 04/24 - Used new remote and found that program for SIS-2 worked successfully with it. 04/27 - Began wiring test circuit for digital potentiometer and writing program to use with Arduino.
04/28 - Debugging POT program. 04/29 - Debugging POT circuit/program. Not getting any voltage off either wiper. 04/30 - Still same problems with POT. Tried rewiring and adjusting program. 05/01 - Still no luck with getting any voltage from POT. Starting to get angry. 05/02 - After further debugging and talking with Matt, have come to the conclusion that AD8402 chip does not work properly. Took video of screen output, showing that buttons are recognized as "up" or "down" and that Arduino was sending info to the SDI pin on the AD8402. Designed and wired circuitry for what the final product should be and wrote program for what the final product would use with Arduino if the AD8402 chip worked. 05/03 - Discovered that it was actually the light bulb that was causing all the problems. DC light bulbs do not have a resistance. Therefore, the voltage output pin on the POT was reacting to being grounded, rather than outputting the desired voltage. Due to this, the original toy idea would not work.