some times we need to dim a LED or we need to speed down the speed of motor . In that situation we need to find the exact value of voltage to the LED or motor . For example if we want to dim a LED we should give it less than 5 volt with the arduino without changing the hardware .
This technique is also applicable To the RGB LED . We need to give different analog voltage value to the three pins so that we can take exact mixed color from the LED . The value is between 0 t0 255 . where 0 is 0 volt and 255 is 5 volt . If you need 2.5 volt the value should be 127 . similarly you can calculate any desired voltage between 0 t0 5 and the mixed output RGB is as shown in figure below.
Let us connect a LED to the to any analog pin of arduino as shown in figure below ( note: analog pins are those pins which is marked ~ . pin number 3,5,69,10,11 are analog output pins ) and write a program as below and observe the result .
Similarly if you want to connect a RGB LED connect three anode pin of LED to different analog pins and give those pins different analog value using function analog write as shown in code above and the output will be mixed .
Same technique is used to control speed of motor , different analog value of output used to vary different output to the output pins .Please read AVR PWM in AVR section for detail .
- getting started with blinky
- different methods of programming
- LED array (display eight LEDs serially)
- Display message on liquid crystal display(LCD)
section-4. introduction to functions and library
section-5. input and output
section-6. sensors and transducers
section-7. motors and relay interfacing
section-8. Liquid crystal display(LCD) interfacing
section-9.seven segments interfacing
section-10.timer and counters
section-12.pulse width modulations (PWM)
section-14.using ethernet shield