32u4 pins not isolated?

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
jhf5167
 
Posts: 9
Joined: Fri Aug 12, 2022 12:26 am

32u4 pins not isolated?

Post by jhf5167 »

Wondering if anyone else has come across this issue, it seems to me like for some reason just on this one board I'm not getting reading properly. All I need is a few buttons to read, but it is just acting weird. Buttons on non-sequential pins to make sure it's not me being dumb, pressing any button gives readings on all others. Tried different wires, different buttons, still same thing. Checked with a meter to see if there were any shorts, no issues there. Any ideas?

Thanks for taking the time to read this.

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: 32u4 pins not isolated?

Post by dastels »

Do you have pullups turned on on those inputs?

Dave

User avatar
jhf5167
 
Posts: 9
Joined: Fri Aug 12, 2022 12:26 am

Re: 32u4 pins not isolated?

Post by jhf5167 »

Yep, tried both with and without pull-ups on all inputs.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: 32u4 pins not isolated?

Post by adafruit_support_bill »

And how do you have your buttons wired? If wired to GND, you need pullups. If wired to VCC you need pull-downs.

User avatar
jhf5167
 
Posts: 9
Joined: Fri Aug 12, 2022 12:26 am

Re: 32u4 pins not isolated?

Post by jhf5167 »

All wired to gnd

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: 32u4 pins not isolated?

Post by adafruit_support_bill »

If you post your code - along with some photos showing all your soldering and connections, we'll see if we can spot the problem.

User avatar
jhf5167
 
Posts: 9
Joined: Fri Aug 12, 2022 12:26 am

Re: 32u4 pins not isolated?

Post by jhf5167 »

No the prettiest connections coz I was already annoyed about it not working and just threw a bunch of different cables at it (btw the one strand that looks like it goes down in the second pic is cut right there and is far from touching anythign else)

EDIT: wow my photography skills aren't great, that green wire connected to nothing is soldered to the the jst connector down the other side not to gnd

This is pretty much the code I was using to test, tried every variation of this (mostly using analogRead to see if it would tell me anything), tried increasing the time between reads with delay() but that didn't help either:

Code: Select all

//int val1 = 0;
int val3 = 0;
int val5 = 0;
int on = 0;
void setup() {
//pinMode(1,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
pinMode(5,INPUT_PULLUP);
}

void loop() {
 on = 0;
 //val1 = analogRead(1);
 val3 = analogRead(3);
 val5 = analogRead(5);
 Serial.println(val3);
}
Attachments
IMG-7374-min.JPG
IMG-7374-min.JPG (797.39 KiB) Viewed 238 times
IMG-7373-min.JPG
IMG-7373-min.JPG (605.53 KiB) Viewed 238 times
IMG-7372-min.JPG
IMG-7372-min.JPG (860.51 KiB) Viewed 238 times
Last edited by dastels on Mon Aug 15, 2022 9:21 am, edited 1 time in total.
Reason: Add code tag

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: 32u4 pins not isolated?

Post by adafruit_support_bill »

For reading switch inputs, you should use digitalRead. I believe analogRead automatically changes the pinmode to INPUT.

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: 32u4 pins not isolated?

Post by dastels »

Bill's right. Using analogRead will remove the pullup.

Dave

User avatar
jhf5167
 
Posts: 9
Joined: Fri Aug 12, 2022 12:26 am

Re: 32u4 pins not isolated?

Post by jhf5167 »

When I have digitalRead, it just gives a 1 no matter what.

User avatar
sj_remington
 
Posts: 998
Joined: Mon Jul 27, 2020 4:51 pm

Re: 32u4 pins not isolated?

Post by sj_remington »

Use your multimeter to verify that a switch actually connects the input to GND, when the button is pressed.

In one photo, it appears that the switches are wired via a blue wire to RST instead of GND.
Last edited by sj_remington on Sun Aug 14, 2022 10:15 pm, edited 3 times in total.

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: 32u4 pins not isolated?

Post by dastels »

jhf5167 wrote: Sun Aug 14, 2022 8:39 pm When I have digitalRead, it just gives a 1 no matter what.
Yes, it sounds like your switches are either miswired or not working.

Dave

User avatar
jhf5167
 
Posts: 9
Joined: Fri Aug 12, 2022 12:26 am

Re: 32u4 pins not isolated?

Post by jhf5167 »

Just tested again with multimeter, all connections seem to be fine. Definitely connected to gnd. Tried with probably 10 switches now, all having the same thing happen.
I think I have a spare nano somewhere, I'll try move everything to that probably this weekend and see if that works

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: 32u4 pins not isolated?

Post by dastels »

Can you post your current code?

Dave

User avatar
jhf5167
 
Posts: 9
Joined: Fri Aug 12, 2022 12:26 am

Re: 32u4 pins not isolated?

Post by jhf5167 »

This is the most recent:

Code: Select all

int val1 = 0;
int val3 = 0;
int val5 = 0;
int on = 0;
void setup() {
pinMode(13, OUTPUT);
//pinMode(1,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
//pinMode(5,INPUT_PULLUP);
}

void loop() {
 //on = 0;
 //val1 = digitalRead(1);
 val3 = digitalRead(3);
 //val5 = digitalRead(5);
 Serial.println(val3);
 /*if (val1 == 0){
    on = 1;
 }
 if (val3 == 0){
    on = 1;
 }
 if (val5 == 0){
    on = 1;
    }
 
 if (on == 1){
    digitalWrite(13,HIGH);
    }
 else{
    digitalWrite(13,LOW);
    }
  */
}

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

Return to “Itsy Bitsy Boards”