Hi,
I tried to use the new card UNO WIFI Rev2 at the place of an UNO (standard).
I use interrupts pin2 and pin3 on UNO and it's work fine.
I compiled the same program with the UNO WIFI Rev2. No problem.
I downloaded it on the card, always OK
A launch the sketch, it seem to work (the input value change when a connect the pin to the ground.
But, with the line "attachInterrupt (digitalPinToInterrupt(2), etatPorte2, CHANGE)", the pin0 react with the interrupt (and not the pin2!).
And for the Pin3, nothing appends!
Any idea ?
Why it is not like the UNO card ?
Unfortunately, the product name is a bit misleading. Other than the form factor, the Uno WiFi Rev2 is actually very different from the Uno. You're going to find that some code which works on the Uno doesn't work on the Uno WiFi Rev2 without some modifications.
@pert Interrupts drove me nuts on the Uno WiFi Rev 2, too. The documentation says "You still define the interrupts with the usual function attachInterrupt(digitalPinToInterrupt(pin), ISR, mode);."
Then, WAY down at the bottom of the attachInterrupt() page is this note"
"For Uno WiFiRev.2, Due, Zero, MKR Family and 101 boards the interrupt number = pin number."
syntax. It's just that on the SAMD Boards, Due, 101, and Uno WiFi Rev2, the interrupt numbers are the same as the pin numbers so you can get by without using the digitalPinToInterrupt macro. It's only on the AVR Boards where digitalPinToInterrupt is mandatory if you want to work with Arduino pin numbers. I don't see any reason why digitalPinToInterrupt couldn't still be implemented so that you use the same attachInterrupt syntax across all boards:
#define digitalPinToInterrupt(pin) (pin)
This results in portable code.
My suspicion is that this is actually a bug in the core library for the Uno WiFi Rev2 that needs to be reported and fixed. Investigating it is on my "To do" list but I'm a bit hampered because I don't own an Uno WiFi Rev2 and don't have a good familiarity with the Arduino megaAVR Boards core library code yet.
I brought my dev code from my regular Uno to my new Uno WiFi Rev 2 and it wouldn't work. I traced it to the interrupt problem. When I used the pin number instead of digitalPinToInterrupt(pin), it worked fine.