HUZZAH32 Input not working

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dtiradar
 
Posts: 5
Joined: Thu Jul 15, 2021 10:50 am

HUZZAH32 Input not working

Post by dtiradar »

I can not seem to get a simple button to work. When using any input I can not turn on LED 13.

I have a pullup resistor in line with switch between ground and power.




// constants won't change. They're used here to set pin numbers:
const int buttonPin = 4; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}

User avatar
dtiradar
 
Posts: 5
Joined: Thu Jul 15, 2021 10:50 am

Re: HUZZAH32 Input not working

Post by dtiradar »

Ok eating Crow. Jumper wire was bad. Meter is a must.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: HUZZAH32 Input not working

Post by adafruit_support_mike »

Glad to hear you caught it, and yes.. instruments are necessary.

We don't have senses for any of the physical properties that make electronics work, so without tools like a multimeter we're literally working blind. The first rule of debugging is "don't believe anything you haven't verified instrumentally"

The second rule is "don't bet the farm on anything you've only measured once, or by only one method." The more different ways you can find to test something, the lower the chance that you're missing something or fooling yourself.. which is incredibly easy to do. Getting the wrong output is a stroll through the park compared to getting the right output for the wrong reason (easier than it sounds).

Legendary analog designer Jim Williams summed up the mindset in Linear Application Note 70:
Jim Williams wrote:When results seem optimal, design an experiment to test them. When results seem poor, design an experiment to test them. When results are as expected, design an experiment to test them. When results are unexpected, design an experiment to test them.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”