All the digital pins are not able to work

Hi Guys,

I have two cores, but recently , i found all the pins are not able to work.Is this related my firmware or hardware ? but i havent chang the firmware as i remember. if the issue comes from the hardware which is strange happing on both.
Btw, the status LED is breath and successfully connected to the Local Cloud.

Below is the simplest code of application.cpp.

#include "application.h"

/* Function prototypes -------------------------------------------------------*/
int tinkerDigitalRead(String pin);

/* This function is called once at start up ----------------------------------*/
void setup() {

	//Register all the Tinker functions
	Spark.function("digitalread", tinkerDigitalRead);

	// Configure the pins to be outputs
	pinMode(D0, OUTPUT);

	// Initialize both the LEDs to be OFF
	digitalWrite(D0, LOW);

/* This function loops forever --------------------------------------------*/
void loop() {


	digitalWrite(D0, HIGH);


int tinkerDigitalRead(String pin) {
	//convert ascii to integer
	int pinNumber = pin.charAt(1) - '0';
	//Sanity check to see if the pin numbers are within limits
	if (pinNumber < 0 || pinNumber > 7)
		return -1;

	if (pin.startsWith("D")) {
		pinMode(pinNumber, INPUT_PULLDOWN);
		return digitalRead(pinNumber);
	} else if (pin.startsWith("A")) {
		pinMode(pinNumber + 10, INPUT_PULLDOWN);
		return digitalRead(pinNumber + 10);
	return -2;

Test result alwasy will be 0:

spark call 51ff6a064987515409381387 digitalread D0

I have also tested others pin that i found the voltage value will be alsways constant ,(Can not be changed by digital write function):

D0 = 0,
D1 = 0,
D2 = 0,
D3 = 1,
D4 = 0,
D5 = 1,
D6 = 0,
D7 = 1

I think there are some things looking odd.

First, since you don’t give a lot of clues what kind of external circuitry you’ve attached to your pins, it’s not clear what signal you want to digitalRead.
Second your statement pinMode(pinNumber, INPUT_PULLDOWN) would explain why you always get zero readings, because the INPUT_PULLDOWN does its job, to attache a pull down resistor to the pin which will pull any open/floating pin down to LOW level.
But then it’s odd that you get HIGH readings for D3, D5 and D7, unless you have got some ext circuitry - which you haven’t said anything about - causing that.

If you only want to test if digitalRead reports back the state you earlier set via a digitalWrite (e.g. the statements in your setup() and loop()) then you’d need to remove the pinMode statement from your tinkerDigitalRead function - for the reason stated above.
pinMode(Dx, INPUTxxx) does set the pin in a way that any state set while it was set as OUTPUT pin will be lost and will either produce floating/random (for INPUT) or always LOW (for INPUT_PULLDOWN) or always HIGH (for INPUT_PULLUP) readings when the pin has no ext signal attached.
But if you leave the pin set as OUTPUT, for quite a while now the digitalRead function will give you the state you’ve set via digitalWrite.


Also, the Tinker app specifically sets the pin mode when a function is called, so you can’t set a digital output to a value and then read back that value on the same pin.

This will return the floating state of D0, not HIGH.

spark call 51ff6a064987515409381387 digitalwrite D0,HIGH
spark call 51ff6a064987515409381387 digitalread D0

Vs this app which will print “1” because we did not change the pinMode() on D0 back to an input before performing a digitalRead()

void setup() {
  // run this once
  pinMode(D0, OUTPUT);
  digitalWrite(D0, HIGH);
  Serial.println( digitalRead(D0) );

void loop() {
  // do nothing

Try converting the Tinker app by commenting out the two lines that contain pinMode() in the tinkerDigitalRead() function.


Hi @ScruffR, @BDub,

My bad, I am wrong understanding the Tinker function ,and never used it before, I just simply copy the Tinker function into my code for testing purpose for convenience, But not read the function carefully.

@ScruffR, I remvoed all circuit just for troubleshooting.

Thx, Thx all, :smile: