Very basic problem...!

Trying to get a project to work on an ITSYBitsy M4. Gone back to basics as my two simple switches did not seem to be working. Just two simple single pole switches that take the pin to GND. Stripped the code back as enclosed but wondered if I'm doing anything wrong with the setup or the assignment?

I have measured the pins on the Arduino when I have the switches shorted to GND and they both read 0 or very close to 0 mV but the digital read always seems to read a 1. I have tried adding additional pull ups to the pins as I read the ITSY does not have pull ups on all pins(assume I wouldn't necessarily get an compile time error for this). I wasnt expecting this to help tbh but wanted to eliminate that as potential.

One thing I am doing is running the external components on seperate psu and for now the ITSY on USB power, have a common ground setup and this seemed fine on my breadboard but now I have moved it to vero encountered some problems! So likely I guess wiring prob but cant understand now I've defo got zero volts on the pin the result I'm getting..

Thanks
dB



#define SWITCH 12
#define TRACE 10

void setup() {
  // put your setup code here, to run once:

  pinMode(SWITCH,INPUT_PULLUP);
  pinMode(TRACE,INPUT_PULLUP);
  Serial.begin(115200);
  delay(3000);

}


int sw,tr,progress=0;

void loop() {


  tr = digitalRead(TRACE);
  sw = digitalRead(SWITCH);

  Serial.println("Values of the pins are:");
  Serial.print("Switch is:");
  Serial.println(sw);

  Serial.print("Trace is:");
  Serial.println(tr);
  
  Serial.println(progress++);
  Serial.println("");
  delay(5000);
}

Then a schematic and clear, well lit, in focus pictures of your wiring would be a good thing to add.

Is there a good tool for creating schematics?

2 Likes

Pen. Paper. Picture taken with camera/phone.

3 Likes

defo?

1 Like

defo = definitely, if I recall correctly.

Yes - we’ll meter says 1-2 mV max bumps up and down to zero.

Adafruit has excellent documentation and getting started guides for their products, along with professional support for their user forum.

Why have you got external pullup resistors in the circuit when you are using INPUT_PULLUP to turn on the built in pullup resistors ?

I added them when I couldnt figure out why I was getting odd results on the pins, I thought maybe they were still floating..I dont think they are required just SCA/SCL are not pulled up as far as I have read. I dont think it should hurt either way.

Nice clear schematic. :slight_smile:

It's so simple it's got to work.

You measure 0V on the pins but say they read high.

How did you measure the voltage on the pins? From ground? Or from 5V?

Completely off the wall thing to try: ignore the switches for the moment and make the pins outputs. Alternate outputting high and low on them at a 1Hz or lower rate. Measure the pins. Do you see them change?

Also: not Vero stripboard by any chance?

Ugh.

Sure.
If you're Australian. I'll just check the doco and get back to you this arvo!

  • Describe how you are measuring the voltage on a pin.
    Show us a picture of your DMM measuring this voltage.

  • Please show us good images of the current wiring which is giving the problem.

What does SCL/SDA have to do with your current circuit....???
....or usb and bat for that matter?
Show what is actually connected to what ....

that's a 3.3v device , 5v pullups may have damaged it . it is not the best way to treat it anyway

1 Like
  • Possibly
    5v - 3v3 - .3(diode) = 1.4v across 10k
    1.4V / 10k = 140uA
    That’s only 140uA thru the protection diodes.

  • Not a good habit.

You have misunderstood. All pins have pull-ups (and pull-downs), but they are disabled for pins that are in I²C mode.

Hi everyone - thanks for all your suggestions. The board was working ok apart from I think I have taken out some of the I/O pins so they were just not working. I think possibly my I2C part which I had taken out of the equation was pushing out 5V not 3V as I had hooked it up to my 5V side. Gonna shift that to the 3V output from the ITSY in future!! Thanks again - honestly thought I was going mad! Just dumb!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.