Read digital pin in nRF52

dev board Adafruit Feather Bluefruit
chip nRF52
features digital read

Before starting

Dependancies

Ensure the following requirements are available:

Pre-requisites

Try these simpler examples:

Buy the components

Description

Read digital pin 16 of nRF52 Adafruit Feather board.

Code

Download code
uint8_t battPin = 16; // Pin 16 on nRF52 Feather Adafruit
int isBattON = 0;

void setup() {
  Serial.begin(115200);
  pinMode(battPin, INPUT_PULLUP);
}

void loop() {
  // Connect pin 16 to GND or 3V3
  isBattON = digitalRead(battPin);
  Serial.print("Batt status: ");
  Serial.println(isBattON);
  delay(2000);
}

Makefile

.PHONY: lint compile upload clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright *.ino

compile:
	arduino-cli compile --fqbn adafruit:nrf52:feather52832 ./

upload:
	adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application ./.*.hex dfu-package.zip
	adafruit-nrfutil dfu serial --package dfu-package.zip -p /dev/tty.SLAB_USBtoUART -b 115200

clean:
	rm -f .*.bin
	rm -f .*.elf
	rm -f .*.hex
	rm -f *.zip

flash: lint compile upload clean