Easy Embedded Programming: Capacitive Touch Sensor

Publié par

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.

Vidéos récentes

Désolé, le filtre sélectionné n’a renvoyé aucun résultat.

Nous avons mis à jour notre politique de confidentialité. Prenez un moment pour lire les changements. En cliquant sur "J'accepte", vous acceptez la clause de confidentialité d'Arrow Electronics ainsi que les conditions d'utilisation.

Notre site Internet place des cookies sur votre appareil pour améliorer votre expérience et pour améliorer notre site. Pour en savoir plus sur les cookies que nous utilisons et la façon de les désactiver, cliquez ici. Des cookies et des technologies de suivi peuvent être utilisés à des fins de marketing. En cliquant sur « Accepter », vous consentez au placement de cookies sur votre appareil et à notre utilisation de technologies de suivi. Cliquez sur « En savoir plus » pour de plus amples informations et instructions sur la façon de désactiver les cookies et les technologies de suivi. Même si l'acceptation des cookies et technologies de suivi est volontaire, leur désactivation peut entraîner un mauvais fonctionnement du site Internet et certaines publicités peuvent être moins pertinentes pour vous. Nous respectons votre confidentialité. Lisez notre politique de confidentialité ici.