{"id":132483,"date":"2023-08-22T18:22:39","date_gmt":"2023-08-22T18:22:39","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=132483"},"modified":"2023-09-20T14:18:14","modified_gmt":"2023-09-20T14:18:14","slug":"raspberry-pi-pico-analog-inputs-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-analog-inputs-arduino\/","title":{"rendered":"Raspberry Pi Pico: Read Analog Inputs (Arduino IDE)"},"content":{"rendered":"\n<p>This guide shows how to read analog values with the Raspberry Pi Pico using Arduino IDE. As an example, we&#8217;ll read the values from a potentiometer, but what you&#8217;ll learn can be applied to any analog sensor\/peripheral.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-Pi-Pico-Analog-Inputs-Arduino-IDE.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico Analog Readings with Arduino IDE\" class=\"wp-image-132496\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-Pi-Pico-Analog-Inputs-Arduino-IDE.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-Pi-Pico-Analog-Inputs-Arduino-IDE.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-Pi-Pico-Analog-Inputs-Arduino-IDE.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-Pi-Pico-Analog-Inputs-Arduino-IDE.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclgreen\">We have a similar guide using MicroPython firmware: <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-analog-inputs-micropython\/\" title=\"\">Raspberry Pi Pico: Read Analog Inputs (MicroPython)<\/a>.<\/p>\n\n\n\n<p>If you\u2019re used to programming the Arduino, ESP32 and\/or the ESP8266 using Arduino IDE, you\u2019ll find that it\u2019s pretty similar to programming the Raspberry Pi Pico.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>You need to install the Raspberry Pi Pico boards on Arduino IDE and you must know how to upload code to the board. Check out the following tutorial first if you haven&#8217;t already:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/programming-raspberry-pi-pico-w-arduino-ide\/\" title=\"\">Programming Raspberry Pi Pico with Arduino IDE<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Analog Readings &#8211; Raspberry Pi Pico<\/h2>\n\n\n\n<p>In this tutorial, you\u2019ll learn how to read an analog input with the Raspberry Pi Pico. This is useful to read values from variable resistors like potentiometers or analog sensors.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-pi-pico-potentiometer.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico Potentiometer\" class=\"wp-image-132492\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-pi-pico-potentiometer.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-pi-pico-potentiometer.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The Raspberry Pi Pico has a 12-bit ADC with four channels on a fixed set of pins (plus an extra internal temperature sensor). This means it can transform an analog signal into a digital signal as a number ranging from 0 to 4095.<\/p>\n\n\n\n<p>It has five ADC channels, but only four are accessible on the GPIOs: GPIO26, GPIO27, GPIO28, and GPIO29. <\/p>\n\n\n\n<p>The first three GPIOs (26, 27, and 28) can be used to read voltage from peripherals, while GPIO29 can be utilized to measure the voltage level of the VSYS supply on the Raspberry Pi Pico board (VSYS is the input voltage that powers the board).<\/p>\n\n\n\n<p>The fifth ADC channel is connected to a built-in temperature sensor.<\/p>\n\n\n\n<p>In summary, here are the key features of the analog pins of the Raspberry Pi Pico board:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>12-bit resolution<\/strong> &#8211; transforms an analog signal into a value between 0 and 4095;<\/li>\n\n\n\n<li><strong>4 ADC channels<\/strong> on external GPIOs;<\/li>\n\n\n\n<li><strong>GPIOs 26, 27, and 28<\/strong> can be used to read output voltage from peripherals;<\/li>\n\n\n\n<li><strong>GPIO29 <\/strong>can measure the <strong>input voltage that powers the board (VSYS)<\/strong>;<\/li>\n\n\n\n<li>There&#8217;s a <strong>fifth ADC channel<\/strong> that is connected to an <strong>internal temperature sensor<\/strong>.<\/li>\n<\/ul>\n\n\n\n<p>Identify the ADC pins on your Raspberry Pi Pico board. They are highlighted in dark green color.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-W-Pinout.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"861\" height=\"620\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-W-Pinout.png?resize=861%2C620&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico W Pinout\" class=\"wp-image-130917\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-W-Pinout.png?w=861&amp;quality=100&amp;strip=all&amp;ssl=1 861w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-W-Pinout.png?resize=300%2C216&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-W-Pinout.png?resize=768%2C553&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 861px) 100vw, 861px\" \/><\/a><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-pinout.png?resize=812%2C619&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico Pinout\" class=\"wp-image-130916\" width=\"812\" height=\"619\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-pinout.png?w=842&amp;quality=100&amp;strip=all&amp;ssl=1 842w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-pinout.png?resize=300%2C229&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-pinout.png?resize=768%2C586&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 812px) 100vw, 812px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclgreen\">To learn more about the Pico Pinout, read the following guide: <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-w-pinout-gpios\/\">Raspberry Pi Pico and Pico W Pinout Guide: GPIOs Explained<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">analogRead()<\/h2>\n\n\n\n<p>Reading an analog input in the Raspberry Pi Pico using the Arduino IDE is as simple as using the&nbsp;<span class=\"rnthl rntliteral\">analogRead()<\/span>&nbsp;function, which accepts as an argument the GPIO you want to read, as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>analogRead(<strong>GPIO<\/strong>);<\/code><\/pre>\n\n\n\n<p>By default, your code will set a 10-bit resolution. To set 12-bit resolution, you can use the <span class=\"rnthl rntliteral\">analogReadResolution()<\/span> function as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>analogReadResolution(12);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Schematic<\/h2>\n\n\n\n<p>Before proceeding, wire a potentiometer to your Raspberry Pi Pico board. You can connect the data pin to any ADC pin. We&#8217;ll use ADC0 on GPIO 26.<\/p>\n\n\n\n<p><strong>New to potentiometers?<\/strong> <a href=\"https:\/\/randomnerdtutorials.com\/electronics-basics-how-a-potentiometer-works\/\" title=\"\">Learn how potentiometers work<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Parts Required<\/h3>\n\n\n\n<p>Here&#8217;s a list of the parts you need to build the circuit:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/raspberry-pi-pico-w\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Raspberry Pi Pico<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/potentiometer-assortment-kit\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Potentiometer<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\" target=\"_blank\">Breadboard<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\">Jumper wires<\/a><\/li>\n<\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Schematic Diagram &#8211; Raspberry Pi Pico<\/h3>\n\n\n\n<p>You can use the following diagram as a reference to connect the potentiometer to the Raspberry Pi Pico board.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"564\" height=\"844\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/raspberry-pi-pico-potentiometer_bb.png?resize=564%2C844&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"raspberry pi pico potentiometer schematic diagram fritzing\" class=\"wp-image-132489\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/raspberry-pi-pico-potentiometer_bb.png?w=564&amp;quality=100&amp;strip=all&amp;ssl=1 564w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/raspberry-pi-pico-potentiometer_bb.png?resize=200%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 200w\" sizes=\"(max-width: 564px) 100vw, 564px\" \/><\/figure><\/div>\n\n\n<p>In this example, we\u2019re using <span class=\"rnthl rntcorange\">GPIO26<\/span> to read analog values from the potentiometer, but you can choose any other GPIO that supports ADC.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code &#8211; Raspberry Pi Pico Read Analog Inputs<\/h2>\n\n\n\n<p>The following code for the Raspberry Pi Pico reads analog values from GPIO 26 and prints the results on the Serial Monitor.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos\n  Complete project details at https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-analog-inputs-arduino\/\n  \n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.\n  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n*********\/\n\n\/\/ Potentiometer is connected to GPIO 26 (Analog ADC0)\nconst int potPin = 26;\n\n\/\/ variable for storing the potentiometer value\nint potValue = 0;\n\nvoid setup() {\n  Serial.begin(115200);\n  analogReadResolution(12);\n  delay(1000);\n}\n\nvoid loop() {\n  \/\/ Reading potentiometer value\n  potValue = analogRead(potPin);\n  Serial.println(potValue);\n  delay(500);\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Raspberry-Pi-Pico\/Arduino\/AnalogRead_Potentiometer.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How the code works<\/h3>\n\n\n\n<p>This code simply reads the values from the potentiometer and prints those values in the Serial Monitor.<\/p>\n\n\n\n<p>In the code, you start by defining the GPIO the potentiometer is connected to. In this example, it&#8217;s GPIO 26.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const int potPin = 26;<\/code><\/pre>\n\n\n\n<p>In the&nbsp;<span class=\"rnthl rntliteral\">setup()<\/span>, we initialize serial communication at a baud rate of 115200.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.begin(<strong>115200<\/strong>);<\/code><\/pre>\n\n\n\n<p>Set 12-bit resolution using the <span class=\"rnthl rntliteral\">analogReadResolution()<\/span> function.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>analogReadResolution(12);<\/code><\/pre>\n\n\n\n<p>If you prefer to use the default 10-bit resolution, you just need to remove this previous line.<\/p>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span>, you use the <span class=\"rnthl rntliteral\">analogRead()<\/span> function to read the analog input from the <span class=\"rnthl rntliteral\">potPin<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>potValue = <strong>analogRead<\/strong>(potPin);<\/code><\/pre>\n\n\n\n<p>Finally, you print the values read from the potentiometer in the serial monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.println(potValue);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Uploading the Code to the Raspberry Pi Pico<\/h2>\n\n\n\n<p>For you to be able to upload code to the Raspberry Pi Pico, it needs to be in bootloader mode.<\/p>\n\n\n\n<p>If the Raspberry Pi is currently running MicroPython firmware, you need to manually put it into bootloader mode. For that, connect the Raspberry Pi Pico to your computer while holding the BOOTSEL button at the same time.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-Bottloader-mode.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico Bootloader mode\" class=\"wp-image-130903\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-Bottloader-mode.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-Bottloader-mode.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>For future uploads using Arduino IDE, the board should go automatically into bootloader mode without the need to press the BOOTSEL button.<\/p>\n\n\n\n<p>Now, select your COM port in <strong>Tools <\/strong>&gt; <strong>Port<\/strong>. It may be the case that the COM port is grayed out. If that&#8217;s the case, don&#8217;t worry it will automatically find the port once you hit the upload button.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"595\" height=\"684\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-Pi-Pico-COM-port-not-showing.png?resize=595%2C684&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico - COM port not found Arduino IDE\" class=\"wp-image-132415\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-Pi-Pico-COM-port-not-showing.png?w=595&amp;quality=100&amp;strip=all&amp;ssl=1 595w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-Pi-Pico-COM-port-not-showing.png?resize=261%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 261w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/figure><\/div>\n\n\n<p>Upload the code.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"30\" height=\"30\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/05\/arduino-2-0-upload-button.png?resize=30%2C30&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino UDE Upload Button\" class=\"wp-image-103678\"\/><\/figure><\/div>\n\n\n<p>You should get a success message.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"595\" height=\"249\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/success-uploading-code-Rpi-pico.png?resize=595%2C249&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico Arduino IDE Done Uploading\" class=\"wp-image-132414\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/success-uploading-code-Rpi-pico.png?w=595&amp;quality=100&amp;strip=all&amp;ssl=1 595w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/success-uploading-code-Rpi-pico.png?resize=300%2C126&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>After uploading the code to the board, open the Serial Monitor at a baud rate of 115200.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"34\" height=\"30\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/10\/Serial-Monitor.png?resize=34%2C30&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Open serial monitor\" class=\"wp-image-120313\"\/><\/figure><\/div>\n\n\n<p>Rotate the potentiometer and see the values changing.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-pi-pico-adjust-potentiometer-analog-read.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico Analog Read Adjust Potentiometer\" class=\"wp-image-132493\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-pi-pico-adjust-potentiometer-analog-read.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-pi-pico-adjust-potentiometer-analog-read.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The maximum value you can get is 4095, and the minimum value is 0.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"713\" height=\"430\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-pi-pico-analog-values-serial-monitor.png?resize=713%2C430&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Read Analog Values Arduino IDE Raspberry Pi Pico\" class=\"wp-image-132487\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-pi-pico-analog-values-serial-monitor.png?w=713&amp;quality=100&amp;strip=all&amp;ssl=1 713w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-pi-pico-analog-values-serial-monitor.png?resize=300%2C181&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 713px) 100vw, 713px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial, you learned about analog reading with the Raspberry Pi Pico. It has five 12-bit ADC channels, four of which are accessible on its GPIOs, and the fifth channel is connected to an internal temperature sensor.<\/p>\n\n\n\n<p>Reading the voltage on a GPIO is as simple as using the <span class=\"rnthl rntliteral\">analogRead()<\/span> function and passing the corresponding GPIO as an argument. This will give you a value between 0 and 4095, in which 0 corresponds to 0V and 4095 to 3.3V<\/p>\n\n\n\n<p>We hope you&#8217;ve found this tutorial useful. If you&#8217;re just getting started with the Raspberry Pi Pico, you may like to read the following tutorials:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/programming-raspberry-pi-pico-w-arduino-ide\/\">Programming Raspberry Pi Pico with Arduino IDE (Pico W compatible)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-w-pinout-gpios\/\">Raspberry Pi Pico and Pico W Pinout Guide: GPIOs Explained<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-outputs-inputs-arduino\/\">Raspberry Pi Pico: Control Digital Outputs and Read Digital Inputs (Arduino IDE)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-pwm-analogwrite-arduino\/\">Raspberry Pi Pico: Fading an LED using PWM (Arduino IDE)<\/a><\/li>\n<\/ul>\n\n\n\n<p><a href=\"https:\/\/randomnerdtutorials.com\/projects-raspberry-pi-pico\/\">Check out all our Raspberry Pi Pico Guides \u00bb<\/a><\/p>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide shows how to read analog values with the Raspberry Pi Pico using Arduino IDE. As an example, we&#8217;ll read the values from a potentiometer, but what you&#8217;ll learn &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Raspberry Pi Pico: Read Analog Inputs (Arduino IDE)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-analog-inputs-arduino\/#more-132483\" aria-label=\"Read more about Raspberry Pi Pico: Read Analog Inputs (Arduino IDE)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":132496,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[324,325],"tags":[],"class_list":["post-132483","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberry-pi-pico","category-raspberry-pi-pico-arduino-ide"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-Pi-Pico-Analog-Inputs-Arduino-IDE.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/132483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=132483"}],"version-history":[{"count":17,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/132483\/revisions"}],"predecessor-version":[{"id":136659,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/132483\/revisions\/136659"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/132496"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=132483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=132483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=132483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}