As the output from the Joystick pins is analogue, we will use ADC to read these Pins. And also I am going to use 4 LEDs to demonstrate the working.
channel
STM32 ADC Multiple Channels
Above is the clock section from the CubeMx. Note that I have selected the ADC clock as 14 MHz. Temp sensor sampling time needs to be 17.1 us.
STM32 ADC single channel
In Single conversion mode the ADC does one conversion and than stops. You can select single conversion in CubeMx by setting…