I noticed that OneButton library does not work with pins A6 and A7 (with A1 and A2 it works good) on my Arduino Nano. Is it because A6 and A7 are Analog only? There is possibility to make them work properly?
sketch example is here https://github.com/mathertel/OneButton/blob/master/examples/TwoButtons/TwoButtons.ino
1 Answer 1
Pins A6 and A7 are analog only pins. They have no digital functionality at all.
You can see that pins 19 and 22 only have ADCn on them - no Pxn for digital operation (ignore the colour scheme of those pins - that's an error in the datasheet).
-
That is what I thought... So is it possible to make OneButton with analog pins?Филипп Цветков– Филипп Цветков05/29/2018 21:40:22Commented May 29, 2018 at 21:40
-
1That is correct. You would have to adapt it to use analogRead() on those pins and compare the incoming values to threshold values for HIGH and LOW. Could be done, but clunky.Majenko– Majenko05/29/2018 21:41:19Commented May 29, 2018 at 21:41
-
In the library, in the function tick, there is the digitalRead call. You could change that line to test if pin a6 or a7 is used and then use code with analogRead. Perhaps the author of the library is willing to add that. You could make an issue and ask for a feature request.Jot– Jot05/30/2018 17:48:15Commented May 30, 2018 at 17:48
Is it because A6 and A7 are Analog?
... why would you would ask that? A1 and A2 are also analog pins. .... please post the sketch that failsIs it because A6 and A7 are "analog only"?