I have a strange issue when reading the input from the arduino nano every. When reading from pins A0 A1 and A2 (have not tried others), I get 1023. However, the exact same code on a nano returns the correct values (536, 60, 642). I stripped down the code to the bare minimum to get the oled to display the outputs and that's it. I have tried on multiple every boards.
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
// put your setup code here, to run once:
Serial.begin( 115200 );
analogReference( DEFAULT );
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0,0); // Start at top-left corner
}
void loop() {
// put your main code here, to run repeatedly:
display.clearDisplay();
display.setCursor(0,0);
display.print(analogRead( A2 ));
display.print(F(" "));
display.print(analogRead( A0 ));
display.print(F(" "));
display.println(analogRead( A1 ));
display.display();
}
Do all analog inputs work as intended if you read a simple 10KOhm potentiometer?
Maybe it's trivial and you've already tried it.
The code seems genuine.
Sorry, what not mentioned? Analog pins have comparators that compare your supply voltage to reference voltage. Say your maximum input is 3.3v and your reference voltage is set to 3.3v, then teh value will be 1024. However if your reference voltage is set to 5v then you will never get more than say 675. And Nano and Nano Every have different default reference voltage for some reason.
Thanks! Fixed! I had read the page but didn't realize it overlapped with the UNO Wi-Fi board. I will be submitting a change request to explicitly mention the nano every