Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Feather Sense Digital I/O Numbers right?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Feather Sense Digital I/O Numbers right?

by petespee on Thu Jun 11, 2020 11:49 am

Hi-
I've written a data logger on the Feather Sense in CircuitPython, but for speed reasons I'm trying to re-write in Arduino.
I've been unable to get the Button to work on D34.
I'm pretty sure my board is good, because the Button most definitely works in CircuitPython.

I'm a novice, but basically trying:

pinMode(34, INPUT_PULLUP); in setup
and then digitalRead(34); to test the value in the main routine.

Is there any way for me to easily check if 34 is the right D for the Button on the Feather Sense?

Thanks anyone for any help you can provide.

petespee
 
Posts: 7
Joined: Sun Jan 13, 2019 11:13 pm

Re: Feather Sense Digital I/O Numbers right?

by petespee on Thu Jun 11, 2020 12:52 pm

I should add that I get random results when I poll the digital pin, no matter if I'm pressing the pin or not. It's like the Pullup Resistor is not there.

I've also tried setting pins D30-D40 as INPUT_PULLUP and returned the status of all of those digital INPUTSs.... the only one that flips is pin 34, and it's unrelated to me pressing the button or not.

You can see the randomness on the 5th number.... this is pin 30 to 40 returned via Serial.

09:46:22.065 -> Button Status 1 1 1 1 0 0 1 0 0 0 0
09:46:23.097 -> Button Status 1 1 1 1 0 0 1 0 0 0 0
09:46:24.098 -> Button Status 1 1 1 1 0 0 1 0 0 0 0
09:46:25.108 -> Button Status 1 1 1 1 1 0 1 0 0 0 0
09:46:26.112 -> Button Status 1 1 1 1 0 0 1 0 0 0 0
09:46:27.118 -> Button Status 1 1 1 1 0 0 1 0 0 0 0
09:46:28.125 -> Button Status 1 1 1 1 1 0 1 0 0 0 0
09:46:29.139 -> Button Status 1 1 1 1 1 0 1 0 0 0 0

petespee
 
Posts: 7
Joined: Sun Jan 13, 2019 11:13 pm

Re: Feather Sense Digital I/O Numbers right?

by petespee on Thu Jun 11, 2020 2:10 pm

I think something is definitely wrong with some digital pins on Arduino for the Feather Sense.

I can get the led on D13 to turn on, but not by using D41 - I have to address it via D13 (even tho the documentation says D41).
Also, the Blue LED on D42 can't be turned on.

Is there a better way to ask support to look into this issue? Might be the board definition? I'm not sure - I'm just a amateur.

Thanks!

petespee
 
Posts: 7
Joined: Sun Jan 13, 2019 11:13 pm

Re: Feather Sense Digital I/O Numbers right?

by mikeysklar on Thu Jun 11, 2020 4:07 pm

Hi Petespee,

Thanks for pointing out your struggled with the LED labeling on the Feather Sense. This is a relatively new board so I think you might be correct the documentation is a little off in the Learn Guide.

I took a look at the schematic and found some things of interest:

https://cdn-learn.adafruit.com/assets/a ... 1583945753

191FB5F9-4050-4640-8333-86FBF90CBBA9.jpeg
191FB5F9-4050-4640-8333-86FBF90CBBA9.jpeg (648.02 KiB) Viewed 235 times


It seems that using 'D13' and 'LED2' should get you access to the LEDs. The LED2 is also under pin3 or p1.10. Please let me know how you fair with some of these different pin numberings.

mikeysklar
 
Posts: 1243
Joined: Mon Aug 01, 2016 8:10 pm

Re: Feather Sense Digital I/O Numbers right?

by adafruit_support_carter on Thu Jun 11, 2020 4:34 pm

Just to make sure - what board are you selecting in the Arduino IDE?

adafruit_support_carter
 
Posts: 15963
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather Sense Digital I/O Numbers right?

by petespee on Thu Jun 11, 2020 4:40 pm

Thanks for the reply.

I had a good look and tried out a few things. I see that LED2 is marked both P1.11 and 4 on the schematic. I have had no luck in Arduino assigning them as follows:

blueled = LED2 (get an error)
blueled = 4 (doesn't work)
redled = 13 works of course

Also, I see the swich on the schematic connected to a number labeled 50. I tried that and it doesn't work either.

And I've selected the Adafruit Feather Bluetooth Sense board. I have attached a screencap of my stripped down code which shows that in the lower right.
Thanks for taking the time to have a look!
Attachments
Screen Shot 2020-06-11 at 1.32.37 PM.png
Arduino IDE
Screen Shot 2020-06-11 at 1.32.37 PM.png (354.6 KiB) Viewed 234 times

petespee
 
Posts: 7
Joined: Sun Jan 13, 2019 11:13 pm

Re: Feather Sense Digital I/O Numbers right?

by adafruit_support_carter on Thu Jun 11, 2020 4:51 pm

Try this example. Should blink red and blue LEDs at different rates and print to serial monitor when button pressed.

Code: Select all | TOGGLE FULL SIZE
#define RED_BLINK (1000)
#define BLUE_BLINK (600)

uint32_t last_red, last_blue;
bool red_led, blue_led;

void setup() {
  Serial.begin(9600);

  pinMode(LED_RED, OUTPUT);
  pinMode(LED_BLUE, OUTPUT);
  pinMode(PIN_BUTTON1, INPUT_PULLUP);

  last_red = millis();
  last_blue = millis();

  red_led = false;
  blue_led = false;
}

void loop() {
  if (millis() - last_red > RED_BLINK) {
    red_led = !red_led;
    digitalWrite(LED_RED, red_led);
    last_red = millis();
   
  }
  if (millis() - last_blue > BLUE_BLINK) {
    blue_led = !blue_led;
    digitalWrite(LED_BLUE, blue_led);
    last_blue = millis();
  }
  if (!digitalRead(PIN_BUTTON1)) {
    Serial.println("Button pressed!");
    delay(250);
  }
}

adafruit_support_carter
 
Posts: 15963
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather Sense Digital I/O Numbers right?

by petespee on Thu Jun 11, 2020 4:57 pm

YES - that works perfectly!

I have to ask tho - how do you access the correct digital outs without specifying the number? What sort of magic is this?
Are there reserved words which come with the board definition somehow, and if so, where can I see a list?

It's like I've seen fire for the first time here.

And thanks for the help! But please don't leave me in this state of ignorance!

petespee
 
Posts: 7
Joined: Sun Jan 13, 2019 11:13 pm

Re: Feather Sense Digital I/O Numbers right?

by adafruit_support_carter on Thu Jun 11, 2020 5:00 pm

It's not magic. Just some #define's buried in the board support files:
https://github.com/adafruit/Adafruit_nR ... /variant.h

Something does seem up with the documentation on that guide page though. You shouldn't have to go digging into the Board Support source code like I did to figure this out. We'll take a look and update the guide as needed.

adafruit_support_carter
 
Posts: 15963
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather Sense Digital I/O Numbers right?

by petespee on Thu Jun 11, 2020 5:04 pm

Thanks so much for your help with this.
I thought i was losing my mind, as I've never struggled with buttons, even at my beginner level!
Will have a look at the doc you linked.
Cheers.

petespee
 
Posts: 7
Joined: Sun Jan 13, 2019 11:13 pm

Re: Feather Sense Digital I/O Numbers right?

by adafruit_support_carter on Fri Jun 12, 2020 1:53 pm

OK, the pinout page has been updated. Looks like the underlying nRF52 pin numbers were being used instead of the Arduino pin numbers. A few of the other pins were also incorrect. But hopefully OK now - let us know if you find anything though.

Thanks for pointing this out.

adafruit_support_carter
 
Posts: 15963
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather Sense Digital I/O Numbers right?

by lambtor on Fri Jun 26, 2020 11:38 am

Is there a pin map reference similar to the adalogger? https://learn.adafruit.com/assets/46243

I'm trying to get the voltage pin so I can calculate battery %. Is battery % calculated the same way on the nrf52840 sense as it is the adalogger? https://learn.adafruit.com/adafruit-fea ... management

lambtor
 
Posts: 6
Joined: Tue Apr 10, 2018 10:09 am

Re: Feather Sense Digital I/O Numbers right?

by adafruit_support_carter on Mon Jun 29, 2020 10:42 am

Here's an easy way to see what pins are available. Works with any CircuitPython board:
Code: Select all | TOGGLE FULL SIZE
Adafruit CircuitPython 5.3.0 on 2020-04-29; Adafruit Feather Bluefruit Sense with nRF52840
>>> import board
>>> dir(board)
['__class__', 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'ACCELEROMETER_GYRO_INTERRUPT', 'AREF', 'BATTERY', 'BLUE_LED', 'D10', 'D11', 'D12', 'D13', 'D2', 'D3', 'D5', 'D6', 'D9', 'I2C', 'L', 'MICROPHONE_CLOCK', 'MICROPHONE_DATA', 'MISO', 'MOSI', 'NEOPIXEL', 'NFC1', 'NFC2', 'PROXIMITY_LIGHT_INTERRUPT', 'RED_LED', 'RX', 'SCK', 'SCL', 'SDA', 'SPI', 'SWITCH', 'TX', 'UART', 'VOLTAGE_MONITOR']
>>>


Use BATTERY. That's the pin connected to the voltage divider. But it can only provide voltage.

adafruit_support_carter
 
Posts: 15963
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather Sense Digital I/O Numbers right?

by lambtor on Mon Jun 29, 2020 4:42 pm

I'm trying to calculate battery % with Arduino. In Arduino, the raw pin input value will be voltage amount?

lambtor
 
Posts: 6
Joined: Tue Apr 10, 2018 10:09 am

Re: Feather Sense Digital I/O Numbers right?

by adafruit_support_carter on Mon Jun 29, 2020 8:00 pm

In Arduino, the raw pin input value will be voltage amount?

It will be the raw ADC conversion value, from which voltage can be computed. Converting that voltage to battery % is much more involved.

If you have further questions about this, please start a new thread.

adafruit_support_carter
 
Posts: 15963
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.