Long since I have posted something(Long since I have done something worth putting here).It is electronics(again) this time.

As from the title, iLighting stands for Intelligent Lighting.Its an LED that adjusts its brightness with respect to the surrounding light.This is accomplished by using an MSP430 G2231 micro controller and an LDR.Here is how the embedded code works.

1.ADC measures drop across the LDR.
MSP430G2331 has a 10 bit ADC,which means it can give an output range of 0-1023.Here,since we are measuring the drop across a resistor(LDR),the maximum value ie 1023 will correspond to the maximum drop,ie minimum resistance,ie minimum light.
2. The ADC output,which is an ordinary number,is compared to numbers corresponding to different voltages in an if-else ladder (refer code lines 42-73).

3.On encountering the appropriate if statement,the pwm() function is invoked.
PWM or pulse width modulation is a technique that is used for the control of power delivered to a circuit or element by modifying the time it stays on or off.For eg,for making a dim lit LED, it is made to stay OFF for more time than it stays ON,say ON for 10 ms and OFF for 90 ms.
4.The above processes continues over and over again.


Now the circuit.I show the MSP430 board as a mere 14 pin IC since i couldn't figure out a better way to show it.The PIN P1.5 is configured for output and P1.4 is configured for input.


And now the code.Its written in C.Hosted in pastebin.Click here for code.
Learn embedded systems online.