cancel
Showing results for 
Search instead for 
Did you mean: 

How to blink a LED with PNUCLEO

MSAMB.1
Associate III

Please I really need help, I am using the P-Nucleo VL6180X, the purpose of my job is to command the opening of a door normally but before that I would already like to succeed in ordering the lighting of an LED.

I use the stmicro API which I am trying to understand with difficulty, in my main program I used the rangeinterrupt () function because for proximity detection it seems to be ideal, however when I flash my program I have 4 horizontal lines on the display of the daughter card and there is no show range already I do not understand why, I have already configured my registers for continuous mode.

On a paper diagram I have simulated the operating principle to turn on the LED, I would use the GPIO1 pin of the daughter board (PB0) to recover the interrupt and send to the MCU and then the MCU will command the lighting of the LED to MCU pin PA5 (daughter board number D13), this looks correct to me,

Here are my questions:

1) I would like to know in the rangeinterrupt function should I take into consideration all the thresholds or should I just keep the sample ready?

2) Where should I set my LED? in the query loop?

3) I would like that when my target is detected that the LED stays on and that it goes off otherwise ;; Do you have any ideas please.

Thanks in advance, it's a job that will really help me so your help will be very precise.

link of the STM32 pin configuration page 32 : https://www.st.com/resource/en/user_manual/dm00105823-stm32-nucleo64-boards-mb1136-stmicroelectronics.pdf

page 4 for nucleo

https://www.st.com/resource/en/application_note/dm00168060-vl6180x-expansion-boards--description-of-version-1-and-version-2-stmicroelectronics.pdf

2 REPLIES 2
T J
Lead

you would normally set up the LED in the initialisation part of main, that's before the While(1) loop.

in the interrupt, you should try to toggle the LED, not turn on then off, it will be too fast to see, do you have a scope ?

the Led may be flashing so fast you cant see it.

at startup before while (1), you could Set the LED on, then call HAL_Delay(1000) and turn it off, then you will know if its setup correctly.

Eleon BORLINI
ST Employee

Hi @MSAMB.1​ ,

did you succeed in setting the LED blink?

-Eleon