I'm working on CY8C4245AXI-483 MCU. I want to write a code to toggle LED through capsense touch button. it means, initially LED is OFF. now when i touch button it should be ON. and remains ON untill i touched it 2nd time. after touching 2nd time it should be in OFF condition and remains in OFF untill i touched it 3rd time and so on.
i found code for same, somewhere on internet. is this correct or i need to change something? Please give me your valuable suggestions.
Thanks & Regards,
/*code starts from here*/
uint fingerpresent_0 = 0;
uint8 wdgt_active = 0;
Solved! Go to Solution.
hi @Hari , Please find below Problem.
I have completed all hardware cydwr properly an TopDesign also. i'm facing difficulties in writting main.c. Please tell me what would be the code for doing this problem.
Please let us know where you are facing issues. This looks like a simple implementation of CapSense. Note that we can help you out with any debugging or corner case issues that you might be facing but not with the implementation of the whole code.
To get you started, you can take a look at the CapSense_IsWidgetActive API for the UP and DOWN buttons. This API returns true whenever a particular button is pressed. This can be used to process the LEDs depending on which button is pressed.
Although I totally agree with Hari-san, I wrote a sample project.
Since I don't have 4 LEDs on my CY8CKIT-042, I just let UART write "*", "* *", "* * *", "* * * *".
I hope that it won't be too difficult to write a program to turn on "real" LEDs in the lines of print("*\n\r") ;
This could be a spoiler, but having a sample to start with is not a bad thing when you (or we) are bewildered.