I am making a motorised touch controlled toy using a microbit and the automation bit. I have successfully enable analog pins 1 and 2 to be touch sensitive but i am having trouble with analogue pin 3. my method for detecting touch is to store an average untouched value for each pin in the start routine thus:
touchval = 0
touch1val = 0
for (let i = 0; i < 10; i++) {
touchval += pins.analogReadPin(AnalogPin.P1)
pins.digitalWritePin(DigitalPin.P1, 1)
basic.pause(1)
}
touch1val = touchval / 10
I then compare this value against a similarly averaged valueto detect touches in the forever routine.
for pins 1 and 2 the averaged untouched value tends to be about 65 and the touched values around 120. but pin3 returns an untouched value of around 540 and a touched value of around 420. not only is this vastly fdifferent to the reading on the other two pins touching seems to reduce rather than increase the value of pin3 if this expected behaviour I can code around it .
can anyone tell me if this is normal or not.
thanks in advance
nick