Build Your Own AI Assistant Part 1 - Creating the Assistant
115007 Views
Is the new Raspberry Pi AI Kit better than Google Coral?
103855 Views
Control Arduino with Python using Firmata / PyFirmata
86426 Views
How to Map with LiDAR - using a Raspberry Pi Zero 2W, RPLidar and Rviz
55270 Views
Node-Red Automation, MQTT, NodeMCU & MicroPython
51306 Views
Creating a Supercomputer with a Raspberry Pi 5 Cluster and Docker Swarm!
50568 Views
Installing and Using DeepSeek-R1:1.5 on a Raspberry Pi with Docker
Gamepad & BurgerBot
Level Up your CAD Skills
Operation Pico
Raspberry Pi Home Hub
Hacky Temperature and Humidity Sensor
Using the Raspberry Pi Pico's Built-in Temperature Sensor
0h 24m
Getting Started with SQL
0h 32m
Introduction to the Linux Command Line on Raspberry Pi OS
0h 42m
How to install MicroPython
0h 8m
Wall Drawing Robot Tutorial
0h 22m
BrachioGraph Tutorial
0h 16m
Learn Linux from the basics to advanced topics.
Learn how to use a Raspberry Pi Pico
Learn MicroPython the best language for MicroControllers
Learn Docker, the leading containerization platform. Docker is used to build, ship, and run applications in a consistent and reliable manner, making it a popular choice for DevOps and cloud-native development.
Learn how to build SMARS robots, starting with the 3D Printing the model, Designing SMARS and Programming SMARS
Learn how to build robots, starting with the basics, then move on to learning Python and MicroPython for microcontrollers, finally learn how to make things with Fusion 360.
Learn Python, the most popular programming language in the world. Python is used in many different areas, including Web Development, Data Science, Machine Learning, Robotics and more.
Learn how to create robots in 3D, using Fusion 360 and FreeCAD. The models can be printed out using a 3d printer and then assembled into a physical robot.
Learn how to create Databases in Python, with SQLite3 and Redis.
KevsRobots Learning Platform
45% Percent Complete
By Kevin McAleer, 3 Minutes
Welcome to Lesson 8 of the Raspberry Pi Pico with MicroPython - GPIO Mastery course. In this lesson, we will explore analog input and the Analog-to-Digital Converter (ADC) on the Raspberry Pi Pico using MicroPython.
Raspberry Pi Pico with MicroPython - GPIO Mastery
In this lesson, you will learn:
Analog input is used to measure the continuous range of values of a physical quantity, such as light, sound, or temperature. In contrast, digital signals represent values in binary format (0s and 1s).
Raspberry Pi Pico uses ADC to convert the continuous analog signal to a discrete digital signal that can be processed by the computer.
To use a pin on the Raspberry Pi Pico for analog input, you need to configure it for analog to digital conversion (ADC). This is done using the ADC class in MicroPython. To configure a pin for ADC, you can use the following code:
ADC
from machine import ADC, Pin # Configure pin 0 for analog input adc = ADC(Pin(0))
Once a pin has been configured for analog input, you can read analog values from it. To read the value of an analog input pin, you can use the read_u16() method of the ADC class. This method returns the value of the analog input pin as a 16-bit unsigned integer between 0 and 65535. For example:
read_u16()
0
65535
from machine import ADC, Pin # Configure pin 0 for analog input adc = ADC(Pin(0)) # Read the value of the analog input pin value = adc.read_u16()
The value variable will contain the value of the analog input pin.
value
In this lesson, you learned about analog input, the role of ADC (Analog to Digital Converter), how to configure Raspberry Pi Pico pins for analog input, and how to read analog values using MicroPython. You can use this knowledge to measure physical quantities, such as light, sound, or temperature, and process them in your Raspberry Pi Pico projects.
After you have completed this lesson, you will have a solid understanding of analog input and the ADC on the Raspberry Pi Pico using MicroPython. You will be able to configure pins for analog input, read analog values from sensors, and process them in your MicroPython programs.
< Previous Next >