Single pin configured as both a cap sensor and as output pin to light a LED

1 post / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everybody,


First to say that I'm a noob with microcontrollers.


I am working with a custom made Qtouch board based on Atmel SAMD21J18B chip. As Atmel START and Qtouch Composer are not properly working on my PC, for my projects I am using an example code where I manually change the number of keys, sliders and adjusting their parameters. As actuators I mainly use LEDs that are being controlled by the touch sensors.


For a current project I would want to "integrate" the LEDs into the touch sensors to serve for indication. This will make my circuit pretty complex though so I came up with the idea to use the LEDs themselves as touch sensors. 


I would like to ask if it is possible to reconfigure a single pin within the program changing its direction from output (driving a LED) to input (a capacitive sensor) and/or back to output?

The idea is that the LED (or the wire to it) will only be used as a sensor when the LED is turned off (no current is flowing).


An example scenario would be:


 - pin configuration as output

 - LED turns on

 - in 500ms LED turns back off

 - pin configuration as a capacitive sensor

 - start reading loop until sensor (LED wire) is touched

 - do some processing

 - repeat from beginning


2. Where in the automatically generated Qtouch code is the configuration of the pin as a sensor done?


Thank you in advance!