Easy Embedded Programming: Capacitive Touch Sensor

Pubblicato da

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.

Video più recenti

Il filtro selezionato non ha restituito alcun risultato.

Non perderti le ultime novità sull'elettronica

Abbiamo aggiornato la nostra politica sulla privacy. Si prega di prendere un momento per rivedere questi cambiamenti. Cliccando su Accetto, l'utente accetta la Politica sulla privacy e Condizioni di utilizzo di Arrow Electronics.

Il nostro sito web mette i cookies sul vostro dispositivo per migliorare la vostra esperienza e il nostro sito. Leggete altre informazioni sui cookies che usiamo e su come disabilitarli qui. I cookies e le tecnologie di tracking possono essere usati per scopi commerciali.

Con un click su “Accept”, voi consentite l'inserimento dei cookies sul vostro dispositivo e l'uso da parte nostra di tecnologie di tracking. Per avere altre informazioni e istruzioni su come disabilitare i cookies e le tecnologie di tracking, clickate su “Read More” qui sotto. Mentre l'accettazione dei cookies e delle tecnologie di tracking è volontaria, una loro disabilitazione potrebbe determinare un funzionamento non corretto del sito web, ed alcuni messaggi di allarme potrebbero essere per voi meno importanti.

Noi rispettiamo la vostra privacy. Leggete qui la nostra politica relativa alla privacy