LED Flash Click Board
LED Flash Click Board
The LED Flash Click Board™ functions as a high power LED photographic flash lamp, and carries the CAT3224 flash LED driver. The Click Board™ is designed to run on a 5V power supply. It communicates with the target microcontroller over the following pins on the MikroBUS lines: AN, RST, PWM, and INT.
Software Support
Code examples for the LED Flash Click Board™, written for MikroElektronika hardware and compilers are available on Libstock.
CODE SNIPPET
The demo is realised as FSM (Finite State Machine). It has four states for controlling output signals (TORCH, FLASH, CHRG).
The demo starts in charge state which enables charge mode. It waits for FLAG signal (active low) from LED driver to switch to ready state. When in ready state, user can press specified button to drive LEDs in flash mode, burst current for short duration of time. After flash state is over (300 ms), it returns to charge state. User, aslo can press specified button to switch between torch or flash states. When in torch state, the program puts LED driver in torch mode, which allows the LEDs to run for extended time.
01 void main() 02 { 03 MCU_Init(); 04 05 state = STATE_CHARGE; 06 next_state = STATE_CHARGE; 07 08 while(1) 09 { 10 switch(state) 11 { 12 case STATE_CHARGE: 13 Write_Mode_Text(1, CL_GRAY, 1, CL_BLACK, 1, CL_GRAY); 14 TORCH = 0; 15 FLASH = 0; 16 CHRG = 1; 17 18 if(!FLAG) 19 next_state = STATE_READY; 20 21 if(Button_Pressed(&GPIO_PORT_64_66, 0, &buttonstate_up)) 22 next_state = STATE_TORCH; 23 24 break; 25 26 case STATE_READY: 27 Write_Mode_Text(0, 0, 0, 0, 1, CL_BLACK); 28 if(Button_Pressed(&GPIO_PORT_64_66, 1, &buttonstate_center)) 29 next_state = STATE_FLASH; 30 31 if(Button_Pressed(&GPIO_PORT_64_66, 0, &buttonstate_up)) 32 next_state = STATE_TORCH; 33 34 break; 35 36 case STATE_FLASH: 37 Write_Mode_Text(0, 0, 0, 0, 1, CL_GRAY); 38 CHRG = 0; 39 40 FLASH = 1; 41 Delay_ms(300); 42 FLASH = 0; 43 44 next_state = STATE_CHARGE; 45 break; 46 47 case STATE_TORCH: 48 Write_Mode_Text(1, CL_BLACK, 1, CL_GRAY, 1, CL_GRAY); 49 TORCH = 1; 50 FLASH = 0; 51 CHRG = 0; 52 53 if(Button_Pressed(&GPIO_PORT_64_66, 0, &buttonstate_up)) 54 next_state = STATE_CHARGE; 55 56 break; 57 } 58 59 state = next_state; 60 Delay_ms(POLLING_PERIOD); 61 } 62 }
LED Flash Click Board
Frequently Asked Questions
Have a Question?
Be the first to ask a question about this.