cancel
Showing results for 
Search instead for 
Did you mean: 

Obejct Sensor Interfacing Doubt

Killstreet30
Associate III

Hello,

I have tried to interface object sensor and all works well the object sensor led works perfectly when the range is close and far( LED is off when the path is blocked and vice versa). But I'm just getting stagnant ADC Values, it's stuck at 4095 in the debugger and the value is not varying at all. Please help. I have configured everything required.

Here's the code:

int main(void)

{

 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

 HAL_Init();

 /* USER CODE BEGIN Init */

 /* USER CODE END Init */

 /* Configure the system clock */

 SystemClock_Config();

 /* USER CODE BEGIN SysInit */

 /* USER CODE END SysInit */

 /* Initialize all configured peripherals */

 MX_GPIO_Init();

 MX_USART2_UART_Init();

 MX_ADC1_Init();

 MX_TIM2_Init();

 /* USER CODE BEGIN 2 */

 /* USER CODE END 2 */

 HAL_ADC_Start(&hadc1);

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

  /* USER CODE END WHILE */

 HAL_ADC_PollForConversion(&hadc1, 100);

 read = HAL_ADC_GetValue(&hadc1);

  /* USER CODE BEGIN 3 */

 }

 /* USER CODE END 3 */

}

0 REPLIES 0