11/*
22 * Analog Correction For Raspberry Pi Pico
33 * https://github.com/Phoenix1747/Arduino-Pico-Analog-Correction
4- *
4+ *
55 * Connect A1 to GND and A0 to VCC (3.3V), then
66 * upload this sketch and restart the Pico.
77 * The connections should be as short as possible!
88 * Your calibration values will be printed to the
9- * Serial Monitor. Paste them into the
9+ * Serial Monitor. Paste them into the
1010 * PicoAnalogCorrection constructor and you're done.
11- *
11+ *
1212 * MIT, 2021, Phoenix1747
1313 */
1414
@@ -23,6 +23,8 @@ void setup() {
2323 pinMode (GND_PIN, INPUT);
2424 pinMode (VCC_PIN, INPUT);
2525
26+ analogReadResolution (12 ); // 12-bit ADC, 4096 channels
27+
2628 // Calibrate ADC using an average of 5000 measurements
2729 pico.calibrateAdc (GND_PIN, VCC_PIN, 5000 );
2830
@@ -39,18 +41,18 @@ void setup1() {
3941void loop () {
4042 Serial.print (" Offset Values: " );
4143 pico.returnCalibrationValues ();
42-
44+
4345 Serial.print (" Uncalibrated GND: " );
4446 Serial.println (pico.analogRead (GND_PIN));
4547 Serial.print (" Calibrated GND: " );
4648 Serial.println (pico.analogCRead (GND_PIN,10 ));
47-
49+
4850 Serial.print (" Uncalibrated VCC: " );
4951 Serial.println (pico.analogRead (VCC_PIN));
5052 Serial.print (" Calibrated VCC: " );
5153 Serial.println (pico.analogCRead (VCC_PIN,10 ));
5254 Serial.println ();
53-
55+
5456 delay (1000 );
5557}
5658
0 commit comments