This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

On Z-stack 1.2.2a.44539 Sample light, which pin is the led connected to?

three leds are defined in hal_board_cfg.h, I did ez-mode and i pressed hal_key_sw_1 on sampleswitch and samplelight both but the state of the LED is not changing. Am I missing something?


/* 1 - Green */
#define LED1_BV BV(0)
#define LED1_SBIT P1_0
#define LED1_DDR P0DIR
#define LED1_POLARITY ACTIVE_HIGH

//#if defined (HAL_BOARD_CC2530EB_REV17)
/* 2 - Red */
#define LED2_BV BV(1)
#define LED2_SBIT P1_1
#define LED2_DDR P1DIR
#define LED2_POLARITY ACTIVE_HIGH

/* 3 - Yellow */
#define LED3_BV BV(4)
#define LED3_SBIT P1_4
#define LED3_DDR P1DIR
#define LED3_POLARITY ACTIVE_HIGH
//#endif

  • What HW do you use? CC2530DK?
  • No, I use my custom hardware that's why I want to know which pin should I connect the led to?
    I tried P1.1, P1.0 and P1.4 but nothing happened
    P1.0 and P1.1 are off while P1.4 is on
  • If you press SW1, it should toggle LED1 which uses P1.0.
  • Yikai Chen,

    it is not happening P1.0 doesn't toggle when i press SW1. 

    I modified to toggle P1.2 to check whether it hits the event, it happens but P1.0 led doesn't toggle. check below code for P1.2 toggle

    static void zclSampleLight_HandleKeys( byte shift, byte keys )
    {
    if ( (HAL_KEY_SW_6))
    {
    giLightScreenMode = LIGHT_MAINMODE;
    P1_2 = ~(P1_2);                         //toggle occurs but P1.0 doesn't toggle

  • Try to use "P1_0 = ~(P1_0);" to toggle P1.0.
  • I want to toggle the led using sampleswitch, so i want to know how the ZCL HA does this?
    SW1 toggles the led which can also be toggled by OTA command I want to know which led is toggled when command is received from sampleswitch to samplelight?
  • SampleSwitch use API zclGeneral_SendOnOff_CmdToggle to send toggle command. SampleLight would receive toggle command in zclSampleLight_OnOffCB and would toggle LED1 (P1.0) in zclSampleLight_DisplayLight().

  • do you mean LED1(P1.0) or (P0.1)?

    The problem is the LED1 never toggles even for the SW1 press to toggle locally

    static void zclSampleLight_HandleKeys( byte shift, byte keys )

    {

     if ( (keys & HAL_KEY_SW_6) && zcl1 == true )

     {

       giLightScreenMode = LIGHT_MAINMODE;

       P1_2 = ~(P1_2);

       // toggle local light immediately

       zclSampleLight_OnOff = zclSampleLight_OnOff ? LIGHT_OFF : LIGHT_ON;                                 ///doesn't work no toggle happens

    #ifdef ZCL_LEVEL_CTRL

       zclSampleLight_LevelCurrentLevel = zclSampleLight_OnOff ? zclSampleLight_LevelOnLevel : ATTR_LEVEL_MIN_LEVEL;

    #endif

  • 1. Sorry, it's my typo. It should be P1.0 and I fix it in my previous reply.

    2. Try the following code:

     if ( (keys & HAL_KEY_SW_6) && zcl1 == true )

     {

       giLightScreenMode = LIGHT_MAINMODE;

       P1_0 = ~(P1_0);

       // toggle local light immediately

       zclSampleLight_OnOff = zclSampleLight_OnOff ? LIGHT_OFF : LIGHT_ON;                                 ///doesn't work no toggle happens

    #ifdef ZCL_LEVEL_CTRL

       zclSampleLight_LevelCurrentLevel = zclSampleLight_OnOff ? zclSampleLight_LevelOnLevel : ATTR_LEVEL_MIN_LEVEL;

    #endif

  • thank you got it i mentioned my toggle command in zclSampleLight_OnOffCB
    it worked
  • You are welcome.