ADS1115 + Nicohood/Nintendo Library not working together

I started working on a project to replicate the Gamecube Controller.

I found a library that that allows me to emulate the Gamecube controller: Home · NicoHood/Nintendo Wiki · GitHub

Unfortunately the Arduino Nano only has 1 ADC when I needed 6. I found the ADS1115 and have 2 of them hooked up to my Arduino nano to read joystick inputs.

The issue is that when I call the read_ADC_SingleEnded() function in loop() the CGamecubeConsole’s write() function does not work. When I comment out the read_ADC_SingleEnded() lines it works but I have no analog inputs.

Can someone explain to me why it’s not working when I try to read from the ADS1115 then write? Is there a workaround?

#include <Adafruit_ADS1115.h>

#include <Nintendo.h>

#define GC_CONSOLE_PIN                        2
#define GC_CONTROLLER_PIN                     7

CGamecubeController gcController(GC_CONTROLLER_PIN);
CGamecubeConsole gcConsole(GC_CONSOLE_PIN);
Gamecube_Data_t gcData = defaultGamecubeData;

Adafruit_ADS1115 analogSticks(0x48);
Adafruit_ADS1115 analogTriggers(0x49);

void setup() {
  analogSticks.begin();
  analogTriggers.begin();
  
  pinMode(3, INPUT_PULLUP);
  ...
  pinMode(A3, INPUT_PULLUP);

  gcController.read();
}

void loop() {
  gcData.report.a = digitalRead(3) == LOW;
  ...
  gcData.report.dleft = digitalRead(A3) == LOW;
  gcData.report.xAxis = map(analogSticks.readADC_SingleEnded(0), 10, 17300, 0, 255);
  gcData.report.yAxis = map(analogSticks.readADC_SingleEnded(1), 10, 17300, 0, 255);
  gcData.report.cxAxis = map(analogSticks.readADC_SingleEnded(2), 10, 17300, 0, 255);
  gcData.report.cyAxis = map(analogSticks.readADC_SingleEnded(3), 10, 17300, 0, 255);
  gcData.report.left = 0;
  gcData.report.right = 0;

  gcConsole.write(gcData);
}

A description of the analog input pins on an Arduino chip (ATmega8, ATmega168, ATmega328P, or ATmega1280).

A/D converter
The ATmega controllers used for the Arduino contain an onboard 6 channel (8 channels on the Mini and Nano, 16 on the Mega) analog-to-digital (A/D) converter. The converter has 10 bit resolution, returning integers from 0 to 1023. While the main function of the analog pins for most Arduino users is to read analog sensors, the analog pins also have all the functionality of general purpose input/output (GPIO) pins (the same as digital pins 0 - 13).

The Arduino Nano you mention has 8 analog input channels, not one. Looking at your code I don’t see the ADS 1015 or ADS1115 libraries called out? I expected to see something like:

#include <Wire.h>
#include <Adafruit_ADS1015.h>
 
Adafruit_ADS1015 ads1015;

before Setup. Then too, never worked with the Nintendo library before.

Ron

Ron

Sorry I was copying and pasting in a hurry and missed the very first line of code where I included the Adafruit_ADS1115 header. I updated my code now.

I understand that the nano has 8 Analog pins but when I try to read from 2 pins at the same time, the values I get are messed up if I do not put a 100 millisecond delay between each analog read (which I can’t do in this project because it gets polled by game every 16 milliseconds). That was why I got the ADS1115 modules.

I am able to see the analog values are correct when I Serial.print them using the ADS1115s. Otherwise the first value would be correct but the ones after that is just a duplicate of the first.