TinyCircuits Forum

TinyCircuits Products => TinyDuino Processors & TinyShields => Topic started by: Bullwinkle on January 25, 2017, 03:40:17 PM

Title: INPUT_PULLUP works for Pin3 but not Pin2
Post by: Bullwinkle on January 25, 2017, 03:40:17 PM
I was intending to use pins 2 AND 3 for interrupt signals that are active LOW.
simplified code:
const int srcOne = 2; // first interrupt source
const int srcTwo = 3; // 2nd interrupt source
void setup() {
  pinMode(srcOne, INPUT_PULLUP);
  pinMode(srcTwo, INPUT_PULLUP);
}
void loop() {
  int s1State = digitalRead(srcOne);
  int s2State = digitalRead(srcTwo);
  SerialMonitorInterface.print("s1:"); SerialMonitorInterface.println(s1State);
  SerialMonitorInterface.print("s2:"); SerialMonitorInterface.println(s2State);
}
....
The result is:
s1:0
s2:1
...   any idea why pin2 behaves differently than expected?  (and Yes, pulling Pin3 LOW is
recognized... s2:0)   I can't conveniently put an external pullup on my Pin2 (due to wiring
constraints) but didn't think I'd need to.  thanks for any inputs! (Pun Intended! :)

===>>> UPDATE:
I *think* I may have identified the source of the behavior I'm seeing.  One of the items
that I've stacked is the Nordic BLE module, which I found uses pin 2 for interrupts.  So,
perhaps the order of my "pinMode(2, INPUT_PULLUP)" then call to BLEsetup() has the pin
function being "superseded"?  I guess I'll have to try eliminating the BLE from the stack and
see if the behavior changes.  I'll post my findings.
Title: Re: INPUT_PULLUP works for Pin3 but not Pin2
Post by: Ben Rose on February 07, 2017, 05:22:27 PM
Yep- the BLE module is using pin 2, it cannot directly be used for another purpose in this setup.