I have read the reference documents and looked over the forum but cannot find much information for the Arduino 101.
I am trying to run some code on a rising edge of a pin input, so to keep the code basic to test I used the follow as per the example but slightly tweaked.
When trying to compile the compiler gets most upset and throws this error message:
'digitalPinToInterrupt' was not declared in this scope
After searching the forum I came up with three answers for this, that the board doesn't support this, this pin cannot be used or the software is not up to date.
Now I know the board supports it as https://www.arduino.cc/en/Main/ArduinoBoard101 says interrupts are supported on all pins, and I also know that the software is up to date as I only got my board a few days ago and have just downloaded the software!
Any nudges in the right direction would be greatly appreciated!
Even if you manage to compile the code it will not work correctly because you are trying to print insode the ISR. Printing uses interrupts. Interrupts are disabled inside an ISR.
UKHeliBob:
Which version of the IDE are you using ?
Even if you manage to compile the code it will not work correctly because you are trying to print insode the ISR. Printing uses interrupts. Interrupts are disabled inside an ISR.
oqibidipo:
You can use the pin number directly in attachInterrupt().
I removed digitalPinToInterrupt(10) and put just 10 as suggested and it compiled and downloaded, but the serial console just repeatedly displayed the test message even though there was no rising edge.
I then disconnected the cable to pin 10 and the message stopped. Now when I plug the cable back into pin 10, even with no load and when it is not connected to anything, the test message scrolls through the serial console.
How does this rising edge work, ive dealt with PLC's previously and to me a rising edge is on the leading edge of a voltage detection, Im quite puzzled as to how plugging in a wire can lead to the sub routine being triggered repeatedly.
UKHeliBob:
Could the wire be acting as an antenna and be picking up an AC voltage thus causing multiple rising edges ?
Im using a breadboard and a jumper wire, the wire was connected into the breadboard with nothing connected to it. I was getting erroneous readings so I removed the wire from the breadboard and left it hanging out the Arduino in mid air and stilll the sub routine ran.
Now when I remove this wire the message stops appearing, but as soon as I plug it back into pin 10, even though there is nothing but fresh air on the other end the message appears back in the serial console. It is confusing me greatly
Now when I jump the 3.3v into pin 13, sure enough as expected, the serial console reads test, and then when I take it out and put it back in it reads test again. Just out of interest I changed it back to pin 10 and it scrolled test repeatedly through the serial console.
I am not sure why this is happening but I am happy it works on a different pin, if anyone can explain why it works on a different pin that would be helpful.
If you connect nothing to an input pin its voltage is ill-defined - the pin floats, picking up capacitively
from everything around it. This is how all CMOS logic behaves - you always have to provide inputs with
a signal, never leave floating (this is typically done with pull-up or pull-down resistors).
MarkT:
If you connect nothing to an input pin its voltage is ill-defined - the pin floats, picking up capacitively
from everything around it. This is how all CMOS logic behaves - you always have to provide inputs with
a signal, never leave floating (this is typically done with pull-up or pull-down resistors).
UKHeliBob:
Pin 13 has extra circuitry to handle the built in LED. The LED turns on when the pin is taken HIGH so perhaps no surprise that it is normally LOW.
Thank you, I fancy myself as a bit of a programmer but my electronics knowledge leaves a lot to be desired!