Published:2013/8/13 21:27:00 Author:lynne | Keyword: The LED Brightness or Fan Speed with Arduino , Tutorial #7 | From:SeekIC
We set the potentiometer pin as 0 (A0 on the Arduino Uno board), the CONTROL variable is the voltage that is used to cotrol the led brightness of the speed of the fan. In the setup() function the CONTROL pin 9 is set as OUTPUT. In the loop() we are getting the analog reading value of the voltage that is applied on pin A0 or 0.
Then use the map() function to translate the value 1024 to 255 and store it in the value variable. After that Arduino writes this value to the CONTROL pin, resulting in a variable voltage that is dependent on the pontetiometer value (its voltage on the adjustable pin, in this case it is connected as a voltage divider *see the schematic).
Reprinted Url Of This Article:
http://www.seekic.com/circuit_diagram/LED_and_Light_Circuit/The_LED_Brightness_or_Fan_Speed_with_Arduino_–_Tutorial_7.html
Print this Page | Comments | Reading(3)
Code: