Easy Embedded Programming: Capacitive Touch Sensor

发布人是

JJ decided to take the easy embedded programming video series further and dive into new combinations; this time he changes the speed of a motor with a capacitive touch sensor.

Hello Everybody, my name is Jean Jacques Meneu and I am an application engineer at Arrow Electronics.

In the first five lessons, we learnt how to spin a motor when an object approaches a proximity sensor. once this is done, it is easy to move forward and learn new combinations. For instance, today, we change the spin of the motor based on the position of our finger on the touch sensor designed on the evalboard provided by Cypress.

We copy the schematic of lesson 5, and we add a component CapSense CSD. We name it CapSense, use the auto tuning method. On the evalboard, it is a linear slider with 5 sensors elements that is designed so we need to enter this configuration. The minimum value of 0 and the maximum value will be 100. When no finger is touching the sensing the element, the return value is 0xFFFF.

As usual, to get all the information about the component, we read the datasheet. In the API section, we find the CapSense_GetCenteroidPos function that gives the position of the finger on the slider. In this paragraph, we can read the function returns 0xFFFF is no sensor is active.

Then the pin out must be configured: the sensing elements are on port 2 from pin1 through pin5 and a last pin called Cmod is on port 4 pin 0. It is time to build the project in order to generate the APIs.

The code is fairly simple. The three CapSense functions are to start the CapSense widget, initialize the sensing elements and enable the scan. We continue to use the interrupt designed in lesson 5 and that triggers an interrupt every 250 ms. The touch sensor has the priority on the proximity sensor. So, we read the value of the touch sensor, if different of 0xFFFF, we modify the speed of the motor by changing the PWM value that drive the motor. If equal to 0xFFFF, we program the speed of the motor based on the proximity sensor value.

最新视频

抱歉,您所选择的筛选条件未返回任何结果。

请仔细阅读我们近期更改的隐私政策。当按下确认键时,您已了解并同意艾睿电子的隐私政策和用户协议。

本网站需使用cookies以改善用户您的体验并进一步改进我们的网站。此处阅读了解关于网站cookies的使用以及如何禁用cookies。网页cookies和追踪功能或許用于市场分析。当您按下同意按钮,您已经了解并同意在您的设备上接受cookies,并给予网站追踪权限。更多关于如何取消网站cookies及追踪的信息,请点击下方“阅读更多”。尽管同意启用cookies追踪与否取决用户意愿,取消网页cookies及追踪可能导致网站运作或显示异常,亦或导致相关推荐广告减少。

我们尊重您的隐私。请在此阅读我们的隐私政策。