Hello,
I'm thinking it might be a hardware problem with my Pico, but I wanted to run it by here just in case I'm missing something, or more likely ... there is something I just don't know that I need to know ...
I've got a Raspberry Pi Pico with a very simple sketch, and a POT connected to it so that I can vary the POT and get different readings from one of the analog pins.
Here is the sketch:
#include <Arduino.h>
int P1 = A0; //GP26 or Pin 31
int P2 = A1; //GP27 or Pin 32
int P3 = A2; //GP28 or Pin 34
unsigned long startTime = millis();
void setup() {
Serial.begin(115200);
pinMode(P1,INPUT);
pinMode(P2,INPUT);
pinMode(P3,INPUT);
delay(8000);
Serial.println("\nPi Pico Ready!");
}
void loop() {
if((millis() - startTime) > 800) {
String a1 = String(analogRead(P1));
String a2 = String(analogRead(P2));
String a3 = String(analogRead(P3));
Serial.println(a1 + " " + a2 + " " + a3);
startTime = millis();
}
}
This is the output from the sketch:
Pi Pico Ready!
4095 4095 4095
4095 4095 4095
4095 4095 4095
4095 4095 4095
4095 4095 4095
4095 4095 4095
4095 4095 4095
...
And here are a couple of pics of the actual setup ... when I pull the green wire off of the pico and read it with my meter, I get exactly what I expect. I get anywhere from 0 to roughly 3.25 volts as I turn the POT ... but I get what you see above from the sketch.
I've tried assigning 26, 27, and 28 to variables P1, P2, and P3, and that did not work either.
Is there something here I'm not getting? Cause it seems like this should be stupid easy to do... or could the pico just be not working properly?
EDIT: I just ran the sketch with my Fluke meter connected at the same time that everything is connected to the Pico, and what is interesting about that is that with the pot cranked all the way up, where I should be reading 3.25 volts on the meter, I'm only reading 2.1 volts, but as soon as I pull that wire off of the Pico, the voltage kicks back up to 3.25 ... so it's like the Pico is sinking current somehow or its acting like a voltage divider ... like there is a resister in series with the circuit when connected... which might actually not be a bad thing though I would not expect it to pull down a supply voltage when it's merely reading it and doing nothing else.
Mike