- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am unable to get smoth operation of toggling led using self capacitance CapSense button
Solved! Go to Solution.
- Tags:
- capsense button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi AjSi_4796051,
That logic is fairly simple again. You need to toggle the LED only once on every successful touch detection. So the firmware would be
uint8 wdgt_active = 0;
for(;;)
{
if(CapSense_NOT_BUSY == CapSense_IsBusy())
{
CapSense_ProcessAllWidgets(); /* Process all widgets */
CapSense_RunTuner(); /* To sync with Tuner application */
if (fingerpresent_0 == 0 && CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID))
{
if(wdgt_active == 0)
{
PWM_1_WriteCompare1(255);
wdgt_active = 1;
}
else
{
PWM_1_WriteCompare1(10);
wdgt_active = 0;
}
fingerpresent_0 = 1;
}
else if (fingerpresent_0 == 1 && !CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID))
{
fingerpresent_0 = 0;
}
CapSense_ScanAllWidgets();
}
}
Best regards,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please find the attached projects where the operation is as follows:
Project 1:
Configured two buttons such that an LED in the kit glows whenever the button is pressed. Send the status of the button through UART only when the status changes. That is, transmit “Button Pressed” or “Button Released” through UART whenever the button is pressed/released respectively and this must only be sent once per change.
Project2:
Configured a linear slider such that the brightness of an LED is adjusted by the finger position and the position must be sent over through UART. Again, it must be sent only once per value. Same value must not be repeated multiple times consecutively.
Hope these helps !
Thanks
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ganesh ,
Tnx for your reply ,
I used project 1 to toggle led ( capsense button pressed led become on and then again button pressed led become off )
But flickerring issue is comming !!
Any solution for that !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi AjSi_4796051
In your case, the for loop can be much simpler.
for(;;)
{
/* Do this only when a scan is done */
if(CapSense_NOT_BUSY == CapSense_IsBusy())
{
CapSense_ProcessAllWidgets(); /* Process all widgets */
CapSense_RunTuner(); /* To sync with Tuner application */
if (CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID)) /* Scan result verification */
{
GREEN_LED_Write(0);
}
else
{
GREEN_LED_Write(1);
}
CapSense_ScanAllWidgets(); /* Start next scan */
}
}
Best regards,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if(CapSense_NOT_BUSY == CapSense_IsBusy())
{
CapSense_ProcessAllWidgets(); /* Process all widgets */
CapSense_RunTuner(); /* To sync with Tuner application */
if (fingerpresent_0 == 0 && CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID))
{
PWM_1_WriteCompare1(255);
fingerpresent_0 = 1;
}
else if (fingerpresent_0 == 1 && CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID))
{
PWM_1_WriteCompare1(10);
fingerpresent_0 = 0;
}
my program is like this but when i pressed the button some time it works fine but some time it fluctuate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi AjSi_4796051
You need to modify the else if condition to
else if (fingerpresent_0 == 1 && !(CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID)))
Notice the negation symbol for the CapSense_IsWidgetActive. This is to turn off the LED only if the widget is not active.
Best regards,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hari,
thanks for your reply !!!
actually I used the led as a feedback, one tap on button to switch on the LED ,then another tap on button to switch off the LED
and as you mentioned , i think it is used for displaying button is active !!!
regards
ajay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you guide me , about the code !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi AjSi_4796051,
That logic is fairly simple again. You need to toggle the LED only once on every successful touch detection. So the firmware would be
uint8 wdgt_active = 0;
for(;;)
{
if(CapSense_NOT_BUSY == CapSense_IsBusy())
{
CapSense_ProcessAllWidgets(); /* Process all widgets */
CapSense_RunTuner(); /* To sync with Tuner application */
if (fingerpresent_0 == 0 && CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID))
{
if(wdgt_active == 0)
{
PWM_1_WriteCompare1(255);
wdgt_active = 1;
}
else
{
PWM_1_WriteCompare1(10);
wdgt_active = 0;
}
fingerpresent_0 = 1;
}
else if (fingerpresent_0 == 1 && !CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID))
{
fingerpresent_0 = 0;
}
CapSense_ScanAllWidgets();
}
}
Best regards,
Hari