Digilent has a set of demo projects for the Arty board. I'm reviewing Arty XADC Demo. I'm going to make a project with an analogue sensor, and that project is a good starting point.
Migrate the Demo from 2016.4
The demo was written for Vivado 2016.4. Migrating to a newer version (in my case: 2020.2) isn't hard. Follow the instructions, but do these corrections before and after project creation.
Before running the create script:
The script uses an older board version, that's not available if you use Digilent's instructions to install board files. Change the script:
# set brd_part "digilentinc.com:arty-s7-50:part0:1.0"
set brd_part "digilentinc.com:arty-s7-50:part0:1.1"
After script execution
The xadc wizard IP is changed. Vivado locks it, and you can't continue unless you remediate. In this case, you upgrade the IP:
Select the convert option, confirm next dialogs.
Once this is fixed, Vivado will run the implementation.
Run the demo
Generate the bitstream and program the device as usual. When you set the 4 switches to the lower position, Arduino input A0 is active and can accept 0 - 3V3 values.
The higher the voltage, the more LEDs will turn on (order LD2 -> LD4 -> LD0 -> LD1).
I attached an LDR circuit to the input.
Here's the result: