{"id":52317,"date":"2026-11-01T10:50:56","date_gmt":"2026-11-01T10:50:56","guid":{"rendered":"http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/"},"modified":"2026-11-01T10:50:56","modified_gmt":"2026-11-01T10:50:56","slug":"potentiometer-analog-input","status":"publish","type":"siratek_tutorial","link":"https:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/","title":{"rendered":"Read a Potentiometer"},"content":{"rendered":"<body><p><\/p>\n<h2>What it does<\/h2>\n<p>A potentiometer is a resistor with a movable contact. Turning the shaft slides that contact along the resistive track, so the voltage at the middle pin varies smoothly between the voltages at the two ends.<\/p>\n<p>This is your first <strong>analog<\/strong> input. A button answers one question: pressed or not. A potentiometer gives a whole range, and the technique is the same one used to read a light sensor, a soil moisture probe, a joystick or a sliding fader. Learn it here on a part you can turn by hand and watch respond, and the sensors later will make sense immediately.<\/p>\n<p>The <code>B10K<\/code> marking means a linear track of 10 kilohms. Linear matters: turning halfway gives roughly half the voltage. An <code>A<\/code> type is logarithmic, used for audio volume, and would not behave the way this tutorial describes.<\/p>\n<h2>Before you begin<\/h2>\n<h3>Required parts and tools<\/h3>\n<ul>\n<li>An Arduino Uno or compatible board, already set up.<\/li>\n<li>One B10K potentiometer.<\/li>\n<li>A breadboard and three jumper wires.<\/li>\n<li>A USB data cable.<\/li>\n<\/ul>\n<h3>How it produces a voltage<\/h3>\n<p>With the two outer pins connected to 5 V and ground, the full 5 V sits across the track. The middle pin, the <strong>wiper<\/strong>, taps off whatever fraction the shaft position selects. Fully one way it reads near 0 V, fully the other near 5 V, and anywhere between gives a proportional value.<\/p>\n<p>This arrangement is a voltage divider, and it is worth recognising because most analog sensors are one: a light-dependent resistor or a thermistor replaces half the track, and the voltage moves as the sensor\u2019s resistance changes.<\/p>\n<h3>What <code>analogRead()<\/code> returns<\/h3>\n<p>The Uno\u2019s analog-to-digital converter has ten bits of resolution, so it reports a whole number from <strong>0 to 1023<\/strong>. Zero means the pin is at ground; 1023 means it is at the reference voltage, which by default is the board\u2019s 5 V supply.<\/p>\n<p>Those are counts, not volts. To convert:<\/p>\n<pre><code>volts = reading * 5.0 \/ 1023.0<\/code><\/pre>\n<p>Only six pins can do this, <code>A0<\/code> to <code>A5<\/code>, and there is one converter shared between them, which is why reading six inputs takes six times as long as reading one.<\/p>\n<h3>Safety notes<\/h3>\n<p>A 10 k potentiometer across 5 V draws about half a milliamp, so nothing here stresses the board. Wire it with the USB cable unplugged all the same.<\/p>\n<h2>Pin reference<\/h2>\n<table>\n<thead>\n<tr>\n<th>Pin or label<\/th>\n<th>Connect to<\/th>\n<th>Purpose<\/th>\n<th>Notes<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Outer pin, either one<\/td>\n<td>Uno <code>5V<\/code><\/td>\n<td>Top of the track<\/td>\n<td>Swapping the two outer pins reverses the direction<\/td>\n<\/tr>\n<tr>\n<td>Middle pin, the wiper<\/td>\n<td>Uno <code>A0<\/code><\/td>\n<td>The varying voltage<\/td>\n<td>Must be the centre pin<\/td>\n<\/tr>\n<tr>\n<td>Outer pin, the other<\/td>\n<td>Uno <code>GND<\/code><\/td>\n<td>Bottom of the track<\/td>\n<td>Required, or the reading will float<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Which outer pin goes to 5 V and which to ground is your choice. It only decides whether clockwise counts up or down.<\/p>\n<figure class=\"siratek-tutorial-figure\"><img decoding=\"async\" src=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/potentiometer-analog-input-wiring.svg\" alt=\"Potentiometer wired to an Arduino Uno, outer pins to 5V and GND, centre pin to A0\" loading=\"lazy\"><figcaption>The centre pin is the wiper. The two outer pins can go either way round.<\/figcaption><\/figure>\n<h2>Wiring steps<\/h2>\n<ol>\n<li>Unplug the USB cable.<\/li>\n<li>Push the potentiometer into the breadboard so each of its three pins is in its own row.<\/li>\n<li>Connect one outer pin to <code>5V<\/code>.<\/li>\n<li>Connect the other outer pin to <code>GND<\/code>.<\/li>\n<li>Connect the middle pin to <code>A0<\/code>.<\/li>\n<li>Check that the middle wire really is on the centre pin. A wire one position across is the usual cause of a reading that jumps between 0 and 1023 with nothing in between.<\/li>\n<li>Plug the USB cable back in.<\/li>\n<\/ol>\n<h2>Software and libraries<\/h2>\n<p>No library is required. <code>analogRead()<\/code> is part of the Arduino core.<\/p>\n<h2>Minimal working example<\/h2>\n<pre><code>\/\/ Siratek: reading a potentiometer.\n\/\/ Prints the raw value and the voltage it represents.\n\nconst int potPin = A0;\n\nvoid setup() {\n  Serial.begin(9600);\n  Serial.println(\"Siratek: turn the potentiometer.\");\n}\n\nvoid loop() {\n  int reading = analogRead(potPin);              \/\/ 0 to 1023.\n  float volts = reading * 5.0 \/ 1023.0;          \/\/ The same value in volts.\n\n  Serial.print(\"reading=\");\n  Serial.print(reading);\n  Serial.print(\"  volts=\");\n  Serial.println(volts, 2);                      \/\/ Two decimal places.\n\n  delay(200);\n}<\/code><\/pre>\n<p>Note that <code>analogRead()<\/code> needs no <code>pinMode()<\/code> call. Analog input is what those pins do by default.<\/p>\n<h3>Using the value for something<\/h3>\n<p>A raw 0 to 1023 is rarely the range you want. <code>map()<\/code> rescales it, and <code>constrain()<\/code> guards against values slightly outside the expected ends.<\/p>\n<p>This version dims the onboard LED, which needs 0 to 255 because <code>analogWrite()<\/code> is eight bits.<\/p>\n<pre><code>\/\/ Siratek: potentiometer controlling LED brightness.\n\nconst int potPin = A0;\nconst int ledPin = 9;   \/\/ Must be a PWM pin, marked with a tilde on the board.\n\nvoid setup() {\n  pinMode(ledPin, OUTPUT);\n  Serial.begin(9600);\n}\n\nvoid loop() {\n  int reading = analogRead(potPin);\n  int brightness = map(reading, 0, 1023, 0, 255);\n\n  analogWrite(ledPin, brightness);\n\n  Serial.print(\"reading=\");\n  Serial.print(reading);\n  Serial.print(\"  brightness=\");\n  Serial.println(brightness);\n\n  delay(50);\n}<\/code><\/pre>\n<p>Pin <code>9<\/code> is used because <code>analogWrite()<\/code> needs a PWM-capable pin. On an Uno those are <code>3<\/code>, <code>5<\/code>, <code>6<\/code>, <code>9<\/code>, <code>10<\/code> and <code>11<\/code>. An LED on pin 9 needs its series resistor, as always.<\/p>\n<h2>Expected result<\/h2>\n<p>Turning the shaft slowly from one end to the other should sweep the reading smoothly from near 0 to near 1023, with the voltage tracking from about 0.00 to about 5.00.<\/p>\n<pre><code>reading=0     volts=0.00\nreading=241   volts=1.18\nreading=512   volts=2.50\nreading=817   volts=3.99\nreading=1023  volts=5.00<\/code><\/pre>\n<p>Two things are normal and not faults. The last digit or two may flicker when the shaft is still, because the converter is reading genuine small electrical noise. And the extreme ends may stop a little short of 0 or 1023 on some parts.<\/p>\n<p>If the jitter is a nuisance, average several readings:<\/p>\n<pre><code>long total = 0;\nfor (int i = 0; i &lt; 8; i++) {\n  total += analogRead(potPin);\n}\nint reading = total \/ 8;<\/code><\/pre>\n<h2>Troubleshooting<\/h2>\n<table>\n<thead>\n<tr>\n<th>Symptom<\/th>\n<th>Likely cause<\/th>\n<th>Check or fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Only ever 0 or 1023, nothing between<\/td>\n<td>Wiper wire not on the centre pin<\/td>\n<td>Move it to the middle pin<\/td>\n<\/tr>\n<tr>\n<td>Always 0<\/td>\n<td><code>5V<\/code> not connected, or wiper at the ground end<\/td>\n<td>Check the outer wire and turn the shaft<\/td>\n<\/tr>\n<tr>\n<td>Always 1023<\/td>\n<td><code>GND<\/code> not connected<\/td>\n<td>Connect the other outer pin to ground<\/td>\n<\/tr>\n<tr>\n<td>Reading drifts with nothing touched<\/td>\n<td>Wiper disconnected, pin floating<\/td>\n<td>Reseat the centre wire<\/td>\n<\/tr>\n<tr>\n<td>Turns the wrong way<\/td>\n<td>Outer pins reversed<\/td>\n<td>Swap them, or swap the ends in <code>map()<\/code><\/td>\n<\/tr>\n<tr>\n<td>Last digits always flicker<\/td>\n<td>Normal converter noise<\/td>\n<td>Average several readings<\/td>\n<\/tr>\n<tr>\n<td>Jumps around mid-travel<\/td>\n<td>Worn or dirty track<\/td>\n<td>Try another potentiometer<\/td>\n<\/tr>\n<tr>\n<td>LED does not dim, only on or off<\/td>\n<td>Not a PWM pin<\/td>\n<td>Use 3, 5, 6, 9, 10 or 11<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Next steps<\/h2>\n<ul>\n<li><strong>Easier first:<\/strong> <em>Seeing What Your Program Is Doing<\/em>, since this tutorial lives in the Serial Monitor.<\/li>\n<li><strong>Related product:<\/strong> the photoresistor, which is read exactly this way but responds to light instead of your hand.<\/li>\n<li><strong>Next project:<\/strong> use the potentiometer to set the speed of the traffic light cycle, replacing the fixed delays with values you can turn.<\/li>\n<\/ul>\n<h2>Sources and attribution<\/h2>\n<p>All text, wiring guidance and code in this tutorial are original Siratek work.<\/p>\n<ul>\n<li>ATmega328P datasheet, for the ten-bit converter resolution.<\/li>\n<li>Arduino core documentation for <code>analogRead()<\/code>, <code>map()<\/code> and <code>analogWrite()<\/code>.<\/li>\n<\/ul>\n<p>No third-party tutorial text, diagrams, photographs or code has been reproduced here.<\/p>\n<p><\/p>\n<\/body>","protected":false},"excerpt":{"rendered":"<p>A potentiometer is a resistor with a movable contact. Turning the shaft slides that contact along the resistive track, so the voltage at the middle pin varies smoothly between the voltages at the two ends.<\/p>\n","protected":false},"featured_media":0,"template":"","siratek_tutorial_level":[],"class_list":["post-52317","siratek_tutorial","type-siratek_tutorial","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Read a Potentiometer - siratek<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Read a Potentiometer - siratek\" \/>\n<meta property=\"og:description\" content=\"A potentiometer is a resistor with a movable contact. Turning the shaft slides that contact along the resistive track, so the voltage at the middle pin varies smoothly between the voltages at the two ends.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/\" \/>\n<meta property=\"og:site_name\" content=\"siratek\" \/>\n<meta property=\"og:image\" content=\"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/potentiometer-analog-input-wiring.svg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/potentiometer-analog-input\\\/\",\"url\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/potentiometer-analog-input\\\/\",\"name\":\"Read a Potentiometer - siratek\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/potentiometer-analog-input\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/potentiometer-analog-input\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/potentiometer-analog-input-wiring.svg\",\"datePublished\":\"2026-11-01T10:50:56+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/potentiometer-analog-input\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/potentiometer-analog-input\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/potentiometer-analog-input\\\/#primaryimage\",\"url\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/potentiometer-analog-input-wiring.svg\",\"contentUrl\":\"https:\\\/\\\/siratek.net\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/potentiometer-analog-input-wiring.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/potentiometer-analog-input\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/siratek.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tutorials\",\"item\":\"https:\\\/\\\/siratek.net\\\/index.php\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Read a Potentiometer\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/siratek.net\\\/#website\",\"url\":\"https:\\\/\\\/siratek.net\\\/\",\"name\":\"siratek\",\"description\":\"Your Best Electronic Retail Shop\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/siratek.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Read a Potentiometer - siratek","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/","og_locale":"en_US","og_type":"article","og_title":"Read a Potentiometer - siratek","og_description":"A potentiometer is a resistor with a movable contact. Turning the shaft slides that contact along the resistive track, so the voltage at the middle pin varies smoothly between the voltages at the two ends.","og_url":"http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/","og_site_name":"siratek","og_image":[{"url":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/potentiometer-analog-input-wiring.svg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/","url":"http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/","name":"Read a Potentiometer - siratek","isPartOf":{"@id":"https:\/\/siratek.net\/#website"},"primaryImageOfPage":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/#primaryimage"},"image":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/#primaryimage"},"thumbnailUrl":"http:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/potentiometer-analog-input-wiring.svg","datePublished":"2026-11-01T10:50:56+00:00","breadcrumb":{"@id":"http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/#primaryimage","url":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/potentiometer-analog-input-wiring.svg","contentUrl":"https:\/\/siratek.net\/wp-content\/uploads\/2026\/11\/potentiometer-analog-input-wiring.svg"},{"@type":"BreadcrumbList","@id":"http:\/\/siratek.net\/index.php\/tutorials\/potentiometer-analog-input\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/siratek.net\/"},{"@type":"ListItem","position":2,"name":"Tutorials","item":"https:\/\/siratek.net\/index.php\/tutorials\/"},{"@type":"ListItem","position":3,"name":"Read a Potentiometer"}]},{"@type":"WebSite","@id":"https:\/\/siratek.net\/#website","url":"https:\/\/siratek.net\/","name":"siratek","description":"Your Best Electronic Retail Shop","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/siratek.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial\/52317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial"}],"about":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/types\/siratek_tutorial"}],"version-history":[{"count":0,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial\/52317\/revisions"}],"wp:attachment":[{"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/media?parent=52317"}],"wp:term":[{"taxonomy":"siratek_tutorial_level","embeddable":true,"href":"https:\/\/siratek.net\/index.php\/wp-json\/wp\/v2\/siratek_tutorial_level?post=52317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}