This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to turn off 12 LEDS together after a certain interval of time? The LEDs are connected using shift register HC595 and bluetooth module nrf51822 is the main module.

There are 12 LEDs which are connected using shift register HC595 ,the module used is nrf51822(bluetooth module). I want the LEDs to go off after 3 seconds interval. My code is as follows-


#include "main.h"
#include "uart.h"
#include "nrf_delay.h"
#include "rc522.h"
#include "hc595.h"
#include "tsm12m.h"
#include "iic.h"
#include "app_timer.h"
#define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */
#define APP_TIMER_OP_QUEUE_SIZE 6

APP_TIMER_DEF(LEDOps);
static void timer_a_handler(void * p_context)
{
lightAllLEDs();
}
static void create_timers()
{
uint32_t err_code;

// Create timers
err_code = app_timer_create(&LEDOps,
APP_TIMER_MODE_SINGLE_SHOT,
timer_a_handler);
APP_ERROR_CHECK(err_code);
}
void timers_init(){
uint32_t err_code;
// Initialize the application timer module.
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
create_timers();
}
void timer_a_start(){
uint32_t err_code;
err_code = app_timer_start(LEDOps, APP_TIMER_TICKS(3,APP_TIMER_PRESCALER), NULL);
APP_ERROR_CHECK(err_code);
}

int main(void)
{
uartInit();
TSM12_Init();
HC595_Init();
timers_init();
timer_a_start();
UartSendstring("123456789");
printf("timer stopped!!");
app_timer_stop(LEDOps);
while(1)
{
TSM12_Handle();
nrf_delay_ms(1);
}
}

The above code doesn't seem to work. I am new to this module. Please help by giving a solution.

Related