Digital In issues
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Digital In issues

by stubleu on Mon Feb 08, 2021 12:49 am

I'm trying to test the Digital In example an a D1 Mini. No problems with the wireless. The only changes I've made are to the username, key, and wifi configurations.
Code: Select all | TOGGLE FULL SIZE
// Adafruit IO Digital Input Example
// Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-digital-input
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
// Written by Todd Treece for Adafruit Industries
// Copyright (c) 2016 Adafruit Industries
// Licensed under the MIT license.
// All text above must be included in any redistribution.

/************************** Configuration ***********************************/

// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients.
#include "config.h"

/************************ Example Starts Here *******************************/

// digital pin 5
#define BUTTON_PIN 5

// button state
bool current = false;
bool last = false;

// set up the 'digital' feed
AdafruitIO_Feed *digital = io.feed("analog");

void setup() {

  // set button pin as an input

  // start the serial connection

  // wait for serial monitor to open
  while(! Serial);

  // connect to io.adafruit.com
  Serial.print("Connecting to Adafruit IO");

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {

  // we are connected


void loop() {

  // io.run(); is required for all sketches.
  // it should always be present at the top of your loop
  // function. it keeps the client connected to
  // io.adafruit.com, and processes any incoming data.

  // grab the current state of the button.
  // we have to flip the logic because we are
  // using a pullup resistor.
  if(digitalRead(BUTTON_PIN) == LOW)
    current = true;
    current = false;

  // return if the value hasn't changed
  if(current == last)

  // save the current state to the 'digital' feed on adafruit io
  Serial.print("sending button -> ");

  // store last button state
  last = current;


I've wired it based on this wiring diagram:
https://learn.adafruit.com/adafruit-io- ... ino-wiring

It connects and the first time the console shows
Code: Select all | TOGGLE FULL SIZE
Connecting to Adafruit IO...............
Adafruit IO connected.

but pushing the button does nothing. I've attached pictures of the wiring. (blue is in 3v3 and purple is in GND. the angle is weird)
d1.png (405.47 KiB) Viewed 120 times
button.png (280.47 KiB) Viewed 120 times

Posts: 2
Joined: Sun Feb 07, 2021 6:06 pm

Re: Digital In issues

by brubell on Mon Feb 08, 2021 11:25 am

I'm not sure if this is an issue with your circuit or with Adafruit IO.

To verify, could you try following the tutorial below for printing a button press to the Arduino serial monitor:

https://learn.adafruit.com/adafruit-ard ... tal-inputs

If you're able to see the status of the button in the serial monitor, let me know, and we'll debug further in this thread.

Posts: 1412
Joined: Fri Jul 17, 2015 10:33 pm

Re: Digital In issues

by stubleu on Thu Feb 11, 2021 12:22 am

*face palm* I realized my error. I was using D5 instead of 5 which would be D0. solved.

Posts: 2
Joined: Sun Feb 07, 2021 6:06 pm

Please be positive and constructive with your questions and comments.