Hi! I’m using an Arduino with a touch sensor. I need the sensor to continuously fire when touched, but it stops after about 8 seconds and then only triggers again after I release my finger and put it back on.
Could there be a workaround like turning the sensor off and on again repeatedly so that the signal stays somewhat stable?
You should post your code so we can attempt to help.
Is the 8 seconds before fire stops constant? It could be overlap of your timer. If yes, turning the timer you use with a larger prescaler will give you more time before next overlap.
Theorically, you touch sensor seems to works properly (like changing a value from 0 to 1) until its value is changed back to 0 by the software, but let you changing again the value to 1 by pressing it again.
Maybe a bad move would be to set a value to 1 when touch sensor was activated, then set the value at 0 only when the sensor is not activated.
I see you use Keyboard library. The author proposes some warnings about the use.
I dont use this one, so it is only presumption: the 8 sec you observe could be a kind of security into the library that stops listening for input.
An idea would be to reset the key before you read the input pin (I code my leds this way, avoiding some remains on). Your code will be flawlessely sending "type nothing/ type "t" instead of repeating "t" (what your code actually do).
Another idea will be to put timer into your code and use Keyboard.press only at regular interval like 10 or 100ms.
you may aslo try a simple manual switch in place of the touch sensor. The switch is not supposed to have a 8sec lifespan, so you can test your code for long period of time.
Hope it will works with a brand new sensor!