Hello
I'm working on sdk v17.
I want the LED to be printed out like a wave when I receive certain data from the app. (5 Times)
It is simple to use 'delay' and 'for' as the code below. But I can't do anything else during the delay. (I must be able to output sensor values, send and receive apps and data, etc.)
static void Left_move()
{
printf("Left MOVE!\n");
for(int i=0; i<5; i++) //5Times
{
nrf_gpio_pin_clear(BAT_LED_1); //LED off
nrf_gpio_pin_clear(BAT_LED_2);
nrf_gpio_pin_clear(BAT_LED_3);
for(int pin=21; pin<25; pin++) //BAT_LED_1,2,3 (pin 22(?),23,24)
{
nrf_gpio_pin_set(pin); //led on
nrf_delay_ms(500);
}
}
static void nus_data_handler(ble_nus_evt_t * p_evt) //send to app
{
uint8_t string_buffer[BLE_NUS_MAX_DATA_LEN+1];
if (p_evt->type == BLE_NUS_EVT_RX_DATA)
{
memcpy(string_buffer, p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
string_buffer[p_evt->params.rx_data.length] = 0;
//Test Left/Right LED move
if(strcmp("1", string_buffer) == 0) //Left
{
//NRF_LOG_INFO("Left LED Moning");
Left_move();
}
}
}
Like this code, how do I use the app_timer to make the LEDs work in sequence at half a second intervals?
Is there anything to refer to?
Thank you in advance.