Jump to content
Sign in to follow this  
yosh

Problem using Capacitive Touch Library on Port1

Recommended Posts

(Sorry for double post, but I think this is a better place to ask than in the Energia-Library Sub Forum)

 

 

I got CapTouch working for Pins 2.x without problems, but not for Pins 1.x (e.g. 1.0, 1.3, 1.4, 1.5, 1.6 and 1.7 - I need 1.1 and 1.2 for serial).

 

I'm using a Rev. 1.5 LP with G2553 and Energia 0101E0012 (Win7, 64bit). Of course I removed the jumpers for 1.0 and 1.6.

Serial output:

Delta on P1.0: 32766 //never changes
Delta on P2.1: 264 //working, here: not touched
Delta on P2.4: 8340 //working, here: touched
Delta on P2.6: -3 //working, here: not touched

Am I missing something? Browsing the source code I didn't found anything that could explain this behaviour.

 

 

Best wishes

yosh

Share this post


Link to post
Share on other sites

The Sketch below works for me on a v1.5 LP with a piece of jumper wire attached to P1.0. Make sure that you remove the jumper from P1.0 that is close to the RED LED. I also verified that it works on the other P1 pins. Can you try the Sketch below and see if that works? Make sure that you hookup the jumper wire or whatever you use for the touch sensor before you reset the LP.

#include <CapTouch.h>

#define LEFT_BUTTON P1_0

#define MIDDLE_LED P1_6

uint8_t state = false;

CapTouch left = CapTouch(LEFT_BUTTON, TOUCH_BUTTON);

void setup() {
  /* Use the middle LED to indicate touch */
  pinMode(MIDDLE_LED, OUTPUT);  
  //left.setThreshold(500);
}

void loop() {
  /* State will be 1 if any of the buttons was touched, otherwise 0 */
  state = left.isTouched();

  /* Turn on the LED if any of the buttons was touched */
  digitalWrite(MIDDLE_LED, state);  
}

Share this post


Link to post
Share on other sites

Thanks for your reply and the Sketch @@energia - it's working. And now I found the problem: CapTouch on Port1 works fine as long as I'm not using Serial. The only modification I made to reproduce this behaviour was

void setup() {
  /* Use the middle LED to indicate touch */
  pinMode(MIDDLE_LED, OUTPUT);  
  //left.setThreshold(500);
 
  Serial.begin(9600);
}

Hmm ... may be some kind of conflict with the Timer?

Share this post


Link to post
Share on other sites

I just discovered a but in the CapTouch library. Line 126 in CapTouch.cpp has to be *sel &= ~bit; instead of *sel &= bit;

With that modification it works perfectly together with Serial. I will fix it and upload a new library.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...