Can't get inputs on QTPY 2040

Adafruit's tiny microcontroller platform. 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.
Locked
User avatar
ChuckDrexel
 
Posts: 13
Joined: Mon Jan 21, 2019 5:40 pm

Can't get inputs on QTPY 2040

Post by ChuckDrexel »

This has got to be and absolute beginners mistake, but I've done this 100 times on other processors of all types. I can't get a simple pushbutton input to work, and I'm at a loss to know what is happening here. Complies, loads and runs, but only shows Inputs equal to 1, regardless of grounding the pins. Got to be something obvious, but I'm not getting it. Help!!! Thanks!

Code: Select all

  int In0=0;
  int In1=1;
  int In2=2;
  int In3=3;
  int inval;
void setup() 
{
  // put your setup code here, to run once:
  pinMode(0,INPUT_PULLUP);
  pinMode(1,INPUT_PULLUP);
  pinMode(2,INPUT_PULLUP);
  pinMode(3,INPUT_PULLUP);
  Serial.begin(9600);
  delay(5000);
  Serial.println("start");
}
void loop() {
  // put your main code here, to run repeatedly:
  inval=digitalRead(In0);
  Serial.print("IN0=");
  Serial.println(inval);
  inval=digitalRead(In1);
  Serial.print("IN1=");
  Serial.println(inval);
  inval=digitalRead(In2);
  Serial.print("IN2=");
  Serial.println(inval);
  inval=digitalRead(In3);
  Serial.print("IN3=");
  Serial.println(inval);
  delay(3000);
}
Last edited by adafruit_support_carter on Fri Apr 28, 2023 2:02 pm, edited 1 time in total.
Reason: added [code] tags

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Can't get inputs on QTPY 2040

Post by adafruit_support_carter »

None of those pins (0-3) are brought out for the QT PY RP2040. See here for pinout info:
https://learn.adafruit.com/adafruit-qt-py-2040/pinouts

User avatar
ChuckDrexel
 
Posts: 13
Joined: Mon Jan 21, 2019 5:40 pm

Re: Can't get inputs on QTPY 2040

Post by ChuckDrexel »

OH!!! That was one thing I ASSUMED - A0 = GPIO0 (NOT!) ALWAYS a bad idea to assume. I accidentally discovered that if I called the pins A0 - A3 it worked fine! Another lesson learned the hard way! Thanks!

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

Return to “Trinket ATTiny, Trinket M0”