Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: Bounce, responsiveRead and velocity for touchRead()

  1. #1

    Bounce, responsiveRead and velocity for touchRead()

    [Originally posted in the wrong thread. Sorry!]

    I thought there should be something like the Bounce library for touchRead() inputs. So I adapted all those functions: risingEdge(), fallingEdge(), duration(), rebounce() etc. and added a few other features like the auto detection of the usable touchRead() range (as it varies depending on your setup and circumstances). There's also an option to make an input latchable.

    I thought there should be a simple way to get quieter variable input too. So I included the "TouchVariable" class for that. And I remembered someone asking about the possibility of velocity sensitivity using touchRead() and I haven't been able to let go of that idea. So there's a "TouchVelocity" class for that.

    See the video

    or the code.

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    That looks Very Cool! Useful extension of touch and well played on the drum line/stick/bar ...

    What is in the drum bar for sensors?

  3. #3
    Quote Originally Posted by defragster View Post
    That looks Very Cool! Useful extension of touch and well played on the drum line/stick/bar ...

    What is in the drum bar for sensors?
    Thank you! The controller is literally just 5 pieces cut from a biscuit tin and sandwiched between a strip of sponge tape and a strip of duct tape.

    Click image for larger version. 

Name:	IMG_5214.jpg 
Views:	7 
Size:	214.1 KB 
ID:	18308Click image for larger version. 

Name:	IMG_5219.jpg 
Views:	8 
Size:	258.4 KB 
ID:	18309

    Next time I won't run the wires under the pads though. You can probably imagine that there's a lot of interference. But, if done right, it could be the makings of very inexpensive velocity-sensitive controllers. It even works on a banana!

    Caveat: I've only gotten this to work under a very specific set of circumstances (laptop on battery power, Teensy stuck directly into the banana). And even then, the responsiveness doesn't stay consistent. But the first step was proving it could be done.

  4. #4
    Junior Member
    Join Date
    Dec 2019
    I've been playing around with the Flicker library a little bit. It initially worked great, but then I added a couple extra touch switches and I seem to have broken the debounce function. Am I initializing the touch switches properly in the setup void?


  5. #5
    Yes, that looks fine. There was a known issue that caused the quiescent touchRead() value to go above the offThreshold when using the ADC. This meant that the input would never go off. Two questions...

    Is that what you are experiencing?
    Do you happen to be using analogRead() anywhere in your code?

    I went ahead and pushed a version of the library with improved setInputRange() and setThreshold() functions to address this. I'm still fine tuning them but please update your library and see if that fixes it.

  6. #6
    Junior Member
    Join Date
    Dec 2019
    I'm trying to put together software to control an integrated amplifier. On initial power up there seems to be a 50/50 shot that the power button and input selector will work perfectly but within a few seconds they start to malfunction. Touching the power button will cause the supply to rattle off and on about 6 times. Input selection will scroll through 5 or 6 inputs. Output selection flies through the outputs too.

    I'm not using analogRead for anything, but I am talking to port expanders and temperature sensors with the wire library and using a couple interrupts for DC detection of the output and overcurrent. The touch switches are a few inches from a switch mode supply but there's a steel shield between them and the supply, possibly this may be affecting the threshold as well?

    I'll try out the updated library later this evening and let you know how it works.

  7. #7
    Junior Member
    Join Date
    Dec 2019
    I've updated the library and tried it again. Operation is the same.

  8. #8
    Junior Member
    Join Date
    Dec 2019
    I've done a little more testing this morning. What I've been finding is on initial power up the touch functions work great. After a short time (a couple seconds) the debounce function is gone on all of the touch switches. If I apply power and don't touch any buttons for a few seconds, the debounce function doesn't work at the first button touch. To me it seems like a timing value is overflowing like an "int" was declared where a long should have been used. On line 75 of the Touch_Velicity.cpp I see the following.

    " newValue = map(int(timer), 9000, MAX_VELOCITY, outHi/2, outHi);"

    Could int(timer) be where my issue is coming from? (Just trying to learn here, I'm a newby to the Arduino world)

  9. #9
    Quote Originally Posted by jwilhelm View Post
    To me it seems like a timing value is overflowing like an "int" was declared where a long should have been used
    No, that 'timer' is an elapsedMillis so it should be fine. I don't think you're using the TouchVelocity class anyway (you only had functions for TouchSwitch and TouchVariable). You can use those functions with specific values too.

    myPowerSwitch.setThreshold(int threshold);
    myPowerVariable.setInputRange(int min, int max);

    Just throw a touchRead() for the power switch pin and a Serial.println() for that value at the bottom of your code. Wait until myPowerSwitch stops working and then take note of the reading you get in the Serail Monitor when you lightly touch it. Replace 'threshold' with that number. Repeat for the other objects.

    Meanwhile I'll mess around with Wire and go bug hunting.
    Last edited by joshnishikawa; 12-27-2019 at 06:57 AM. Reason: Because that's how I'm living.

  10. #10
    Thanks, I'm using this in a project! It made using the touch inputs quite easy, and just like Bounce.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts