2288 views|5 replies

1455

Posts

1

Resources
The OP
 

[Evaluation of Anxinke Bluetooth Development Board PB-02-Kit] Light up the LED [Copy link]

Since the Anxinke Bluetooth development board is a development board for Bluetooth applications, the onboard peripheral resources are relatively few, only two categories, namely: one is RGB_LED, and the other is 2 independent LEDs. The schematic diagram is shown in Figure 1.

Figure 1 LED circuit

With the schematic diagram above, you have the pin number to control the LED.

For some reason, since an example of the GPIO port is provided in the routine, why not light up an LED to give everyone some light?

Since there are none, let's light them up ourselves. If that's not enough, just light up a few more!

1. Turn on the warm light

The main program for lighting up the warm-colored lights is:

int app_main(void)
{
 /* Initialize the operating system */
 osal_init_system();
 osal_pwrmgr_device( PWRMGR_BATTERY );
hal_gpio_pin_init(0, 1);
hal_gpio_write(0, 1);
/* Start OSAL */
 osal_start_system(); // No Return from here
 return 0;
}

After the program is downloaded, its execution effect is shown in Figure 2.

Figure 2: Light up the warm light

2. Turn on the cold and warm lights

Based on lighting the warm light, the procedure for lighting the warm and cold lights is as follows:

int app_main(void)
{
 /* Initialize the operating system */
 osal_init_system();
 osal_pwrmgr_device( PWRMGR_BATTERY );
 hal_gpio_pin_init(0, 1);
 hal_gpio_write(0, 1);
 hal_gpio_pin_init(P34, 1);
 hal_gpio_write(P34, 1);
 /* Start OSAL */
 osal_start_system(); // No Return from here
 return 0;
}

After the program is downloaded, its execution effect is shown in Figure 3.

Figure 3: Light up the cold and warm dual lights

3. Flashing effect

Since the LED can be lit, the project LED is not a problem. The LED flashing can be realized through delay processing. The program for LED flashing is:

int app_main(void)
{
     /* Initialize the operating system */
 osal_init_system();
 osal_pwrmgr_device( PWRMGR_BATTERY );
 hal_gpio_pin_init(P0, OEN);
 hal_gpio_write(P0, 1);
 hal_gpio_pin_init(P15, OEN);//R
 hal_gpio_write(P15, 1);
 hal_gpio_pin_init(P34, OEN);//B
 hal_gpio_write(P34, 1);
 while(1)
 {
  for(i=0;i<1000;i++)
  for(j=0;j<2000;j++);
 hal_gpio_write(P34, 1);
  for(i=0;i<1000;i++)
  for(j=0;j<2000;j++);
 hal_gpio_write(P34, 0);
 }
  /* Start OSAL */
  osal_start_system(); // No Return from here
 return 0;
}

Of course, the delay statement can also be separated into an independent function, the content of which is:

void delay(int ms)
{
 int i,j;
 for(i=0;i<ms;i++)
 for(j=0;j<2000;j++);
}

The main program using the delay function is:

int app_main(void)
{
 /* Initialize the operating system */
 osal_init_system();
 osal_pwrmgr_device( PWRMGR_BATTERY );
 hal_gpio_pin_init(P0, OEN);
 hal_gpio_write(P0, 1);
 hal_gpio_pin_init(P15, OEN);
 hal_gpio_write(P15, 1);
 hal_gpio_pin_init(P34, OEN);
 hal_gpio_write(P34, 1);
 while(1)
 {
              delay(1000);
 hal_gpio_write(P34, 1);
              delay(1000);
 hal_gpio_write(P34, 0);
 }
  /* Start OSAL */
  osal_start_system(); // No Return from here
 return 0;
}

4. Light up all LEDs

In addition to the cold and warm LEDs, there is also an RGB_LED on board. The program to light up all the LEDs is:

int app_main(void)
{
 /* Initialize the operating system */
 osal_init_system();
 osal_pwrmgr_device( PWRMGR_BATTERY );
  hal_gpio_pin_init(P0, OEN);
  hal_gpio_write(P0, 1);
 hal_gpio_pin_init(P34, OEN);
 hal_gpio_write(P34, 1);
 hal_gpio_pin_init(P23, OEN);
 hal_gpio_write(P23, 1);
 hal_gpio_pin_init(P18, OEN);
 hal_gpio_write(P18, 1);
 hal_gpio_pin_init(P15, OEN);
 hal_gpio_write(P15, 1);
 while(1)
 {
             delay(1000);
 hal_gpio_write(P34, 1);
             delay(1000);
 hal_gpio_write(P34, 0);
 }
  /* Start OSAL */
 osal_start_system(); // No Return from here
 return 0;
}

After the program is downloaded, its execution effect is shown in Figure 4.

Figure 4 Light up all LEDs

In addition, the external LED module can be lit up through the expansion interface, and the effect achieved is shown in Figure 5.

Figure 5 Lighting up the external LED module

This post is from RF/Wirelessly

Latest reply

Awesome, but why doesn't my board light up after downloading?  Details Published on 2022-6-21 12:05
 

6593

Posts

0

Resources
2
 

It is convenient to control smart light sources

This post is from RF/Wirelessly
 
 

2w

Posts

74

Resources
3
 

Although the light is small, the color is dazzling. Looking forward to the follow-up.

This post is from RF/Wirelessly
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle

Comments

Thanks for your support!!!  Details Published on 2021-11-19 10:38
Personal signature

加油!在电子行业默默贡献自己的力量!:)

 
 
 

1455

Posts

1

Resources
4
 
soso posted on 2021-11-19 10:04 Although the light is small, the color is very dazzling. Looking forward to the follow-up.

Thanks for your support!!!

This post is from RF/Wirelessly
 
 
 

53

Posts

0

Resources
5
 

Thank you very much, it is very good for controlling lights, and it can also be changed to voice control

This post is from RF/Wirelessly
 
 
 

1

Posts

0

Resources
6
 
Awesome, but why doesn't my board light up after downloading?
This post is from RF/Wirelessly
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

快速回复 返回顶部 Return list