Simple Proximity Sensor Demo on PSoC6 for MTB2.2

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Kenshow
Level 8
Level 8
Distributor - Marubun (Japan)
50 solutions authored 25 solutions authored 10 solutions authored

Hello,

I wanted a simple proximity sensor demo that would work on ModusToolbox, but there isn’t one, so I made one.

The base was based on the CapSense sample for MTB and CE218137.

1.png

 

The environment used is as follows:

・ModusToolbox 2.2.1

・CY8CKIT-062-BLE

 

The settings of the peripherals (Pin and CapSense) are the same as CE218137, but they are set for ModusToolbox.

First, the CapSense settings are configured in the CapSense Configurator, which is the same as CE218137.

 2.png

3.png

4.png

5.png

The LED and PWM are set programmatically, as it is using the CapSense sample for ModusToolbox.

The touch process is as follows:

 -----------------

static void process_touch(void)

{

    static uint32_t  currentProxData = 0u;

    static led_data_t led_data = {LED_ON, LED_MAX_BRIGHTNESS};

 

    if(CY_CAPSENSE_PROXIMITY0_SNS0_DIFF0_VALUE   >

    CY_CAPSENSE_PROXIMITY0_FINGER_TH_VALUE)

    {

        /*If proximity value is not within the range, cap the value */

                if((CY_CAPSENSE_PROXIMITY0_SNS0_DIFF0_VALUE -

                                CY_CAPSENSE_PROXIMITY0_FINGER_TH_VALUE)

            <= UINT8_MAX)

                {

            /* Store the proximity data */

                 currentProxData =  (uint8_t)(CY_CAPSENSE_PROXIMITY0_SNS0_DIFF0_VALUE -

                         CY_CAPSENSE_PROXIMITY0_FINGER_TH_VALUE);

                }

        /* Store the maximum value otherwise */

        else

        {

            currentProxData = (uint8_t)UINT8_MAX;

        }

    }

     led_data.brightness = currentProxData;

     update_led_state(&led_data);

}

 ----------------- 

CapSense Tuner can be used in this sample, so please use it for fine adjustment.

 

Thanks,

Kenshow

1 Reply
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Hello @Kenshow ,

Thank you for sharing this example project with the community. Appreciate your effort in creating this 🙂

Regards,
Dheeraj

0 Likes