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.
32u4 pins not isolated?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- dastels
- Posts: 15662
- Joined: Tue Oct 20, 2015 3:22 pm
Re: 32u4 pins not isolated?
Do you have pullups turned on on those inputs?
Dave
Dave
- jhf5167
- Posts: 9
- Joined: Fri Aug 12, 2022 12:26 am
Re: 32u4 pins not isolated?
Yep, tried both with and without pull-ups on all inputs.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: 32u4 pins not isolated?
And how do you have your buttons wired? If wired to GND, you need pullups. If wired to VCC you need pull-downs.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: 32u4 pins not isolated?
If you post your code - along with some photos showing all your soldering and connections, we'll see if we can spot the problem.
- jhf5167
- Posts: 9
- Joined: Fri Aug 12, 2022 12:26 am
Re: 32u4 pins not isolated?
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:
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 (797.39 KiB) Viewed 238 times
-
- IMG-7373-min.JPG (605.53 KiB) Viewed 238 times
-
- 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
Reason: Add code tag
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: 32u4 pins not isolated?
For reading switch inputs, you should use digitalRead. I believe analogRead automatically changes the pinmode to INPUT.
- dastels
- Posts: 15662
- Joined: Tue Oct 20, 2015 3:22 pm
Re: 32u4 pins not isolated?
Bill's right. Using analogRead will remove the pullup.
Dave
Dave
- jhf5167
- Posts: 9
- Joined: Fri Aug 12, 2022 12:26 am
Re: 32u4 pins not isolated?
When I have digitalRead, it just gives a 1 no matter what.
- sj_remington
- Posts: 998
- Joined: Mon Jul 27, 2020 4:51 pm
Re: 32u4 pins not isolated?
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.
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.
- dastels
- Posts: 15662
- Joined: Tue Oct 20, 2015 3:22 pm
- jhf5167
- Posts: 9
- Joined: Fri Aug 12, 2022 12:26 am
Re: 32u4 pins not isolated?
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
I think I have a spare nano somewhere, I'll try move everything to that probably this weekend and see if that works
- dastels
- Posts: 15662
- Joined: Tue Oct 20, 2015 3:22 pm
Re: 32u4 pins not isolated?
Can you post your current code?
Dave
Dave
- jhf5167
- Posts: 9
- Joined: Fri Aug 12, 2022 12:26 am
Re: 32u4 pins not isolated?
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);
}
*/
}
Please be positive and constructive with your questions and comments.