• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeArduinoAdvanced Learning Kit for ArduinoExperiment 2: Experiment with Potentiometer
Previous Next

Experiment 2: Experiment with Potentiometer

Posted by: admin , November 7, 2013

[vc_row][vc_column width=”1/1″][vc_column_text]A potentiometer is a simple knob that provides a variable resistance.

In this experiment, we are going to use WXD3-13-2W 10K ohm rotatory potentiometer.

poten_1

Specification of WXD3-13-2W 10K ohm:

1. Range of resistance: 0 ohm – 10K ohm +2%

2. Power: 2W

[/vc_column_text][vc_tour][vc_tab title=”BOM” tab_id=”1383866706-1-33″][vc_column_text]This experiment uses the Arduino board package (Arduino Uno, USB cable, breadboard and jumper wires), and the following:

1 x WXD3-13-2W 10K ohm potentiometer.

1 x LED

1 x Resistor of 220 ohm

Several jumper wires.[/vc_column_text][/vc_tab][vc_tab title=”Wire Diagram” tab_id=”1383866706-2-19″][vc_column_text]The terminals of the potentiometer is illustrated below:

poten_2

poten_3

[/vc_column_text][/vc_tab][vc_tab title=”Principle” tab_id=”1383867794540-2-4″][vc_column_text]Connect the positive leg of LED to one of the PWM pin of Arduino ( the pin marked with ~).  We connect the terminal with variable resistance to the ADC port, and use Arduino to read the analog port value and control the brightness of LED.[/vc_column_text][/vc_tab][vc_tab title=”Code” tab_id=”1383867883184-3-1″][vc_column_text]

/*
Comments: use potentiometer to control the brightness of LED
*/
int led=11;
void setup()
{
pinMode(led,OUTPUT);
//The pin must support PWM
}

void loop()
{
int n = analogRead(A0);
//Read analog value (0-5V means reading og 0-1203)
analogWrite(led,n/4);
//The max of PWM is 255. So we need to divide the value by 4
}

[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]

Tags: Advanced Learning Kit for Arduino

Share!
Tweet

admin

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors