Using SpiDevice spi = SpiDevice.Create(hardwareSpiSettings) Var hardwareSpiSettings = new SpiConnectionSettings(0, 0) Replace the contents of Program.cs with the following code: using System NET CLI from the project directory or Visual Studio. dotnet new console -o AdcTutorialĪdd the package to the project. Create the appĬomplete the following steps in your preferred development environment:Ĭreate a new. Refer to the following pinout diagrams as needed: MCP3008Ī GPIO breakout board in conjunction with a breadboard is recommended to streamline connections to the GPIO header. Supply 3.3V and ground to the outer pins on the potentiometer. CH0 to variable (middle) pin on potentiometer (yellow).The following are the connections from the MCP3008 to the Raspberry Pi and potentiometer:
The MCP3008 uses Serial Peripheral Interface (SPI) to communicate. Use the hardware components to build the circuit as depicted in the following diagram: Use the raspi-config command to ensure the following two services are enabled:įor more information on raspi-config, refer to the Raspberry Pi documentation. Raspberry Pi GPIO breakout board (optional/recommended).Raspberry Pi (2 or greater) with Raspberry Pi OS installed.NET to read values from an ADC as you modulate the input voltage with a potentiometer. ADCs are used for reading values from thermistors, potentiometers, and other devices that change resistance based on certain conditions. An analog-to-digital converter (ADC) is a device that can read an analog input voltage value and convert it into a digital value.