Friday, August 7, 2015

Controlling the LED Brightness #Learn Arduino

Finally I can go up from blink to another basic of Arduino. In this circuit we can control the brightness of LED with potentiometer.LED brightness is determined from the position knob on the potentiometer.

Some material we need:
  • Arduino (I am using Arduino UNO)
  • LED
  • Potentiometer 10K ohm
  • 330 Ohm resistor
  • PC/laptop
  • Breadboard
  • 6 jumperwire
  • Data cable from Arduino to PC 
 Here is the code that we can simply copying from Arduino IDE example:

the new things we learn in here is "sensorPin =A0". It means that we select the input pin for the potentiometer. To read the value from the sensor we just type "sensorValue = analogRead(sensorPin);"  inside the loop.

No comments: