The MCP4802 is a dual 8-Bit Digital Analog Converter with SPI interface. The MCP4822 is the 12-Bit version.
To connect the MCP 4802 to the Raspberry Pi connect the SPI pins of the MCP4802 like that:
MCP4802 Raspberry Pi Vdd 5V CS CE1 SCLK SCLK SDI MOSI Vss GND LDAC GND
Before using the Wiring object enable the SPI interface in:
$ sudo raspi-config
https://swharden.com/blog/2016-09-28-generating-analog-voltages-with-the-raspberry-pi/
to output some voltage:
$ echo -ne "\x1F\xFF" > /dev/spidev0.1
https://www.airspayce.com/mikem/bcm2835/
https://www.youtube.com/watch?v=0QcteUtzB4o
https://raspberry-projects.com/pi/programming-in-c/spi/using-the-spi-interface
#include <wiringPiSPI.h>
http://wiringpi.com/reference/spi-library/
https://projects.drogon.net/raspberry-pi/wiringpi/spi-library/
https://projects.drogon.net/raspberry-pi/gertboard/analog-inout/
https://projects.drogon.net/understanding-spi-on-the-raspberry-pi/
https://www.petervis.com/Raspberry_PI/Gertboard_Raspberry_Pi_Expansion/Gertboard_Digital_to_Analog_Converter.html
https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial/all