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);
}
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.
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?
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!