hi there,
if i have an i2c display attached to SCL0 and SDA0 on the alternative pins 7 and 8, how do i free up A4 and A5 for analog readings? currently they are somehow not getting correct readings. do i need to disable i2c on A4 and A5 somehow? if i comment all parts associated with the i2c display my readings on A4 and A5 are correct, hence the wiring is good.
find my current test code below:
EDIT: i already found the issue! the display contstructor needs to be changed to:
if i have an i2c display attached to SCL0 and SDA0 on the alternative pins 7 and 8, how do i free up A4 and A5 for analog readings? currently they are somehow not getting correct readings. do i need to disable i2c on A4 and A5 somehow? if i comment all parts associated with the i2c display my readings on A4 and A5 are correct, hence the wiring is good.
find my current test code below:
Code:
#include <Arduino.h>
#include <U8x8lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#include <Wire.h>
U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA);
void setup(void)
{
Wire.setSDA(8);
Wire.setSCL(7);
analogReadResolution(11);
pinMode(24, INPUT);
pinMode(25, INPUT);
pinMode(26, INPUT);
pinMode(27, INPUT);
pinMode(28, INPUT);
u8x8.begin();
u8x8.setPowerSave(0);
}
void loop(void)
{
int xaxis = analogRead(A9);
int xhothand = analogRead(A13);
int xjoystick = analogRead(A14);
int yjoystick = analogRead(A15);
int efsr = analogRead(A16);
int afsr = analogRead(A17);
int dfsr = analogRead(A18);
int gfsr = analogRead(A19);
int arpfsr = analogRead(A20);
int jogwheel = analogRead(A21);
int allfsr = analogRead(A22);
int etrig = analogRead(A4);
int atrig = analogRead(A5);
int dtrig = analogRead(A6);
int gtrig = analogRead(A7);
int arpsoftpot = analogRead(A8);
int esoftpot = analogRead(A0);
int asoftpot = analogRead(A1);
int dsoftpot = analogRead(A2);
int gsoftpot = analogRead(A3);
int button1 = digitalRead(24);
int button2 = digitalRead(25);
int button3 = digitalRead(26);
int button4 = digitalRead(27);
int button5 = digitalRead(28);
Serial.println("New Readings:");
Serial.print("Accelerometer:");
Serial.println(xaxis);
Serial.print("Hothand:");
Serial.println(xhothand);
Serial.print("Joystick:");
Serial.println(xjoystick);
Serial.println(yjoystick);
Serial.print("E-FSR:");
Serial.println(efsr);
Serial.print("E-Softpot:");
Serial.println(esoftpot);
Serial.print("A-FSR:");
Serial.println(afsr);
Serial.print("A-Softpot:");
Serial.println(asoftpot);
Serial.print("D-FSR:");
Serial.println(dfsr);
Serial.print("D-Softpot:");
Serial.println(dsoftpot);
Serial.print("G-FSR:");
Serial.println(gfsr);
Serial.print("G-Softpot:");
Serial.println(gsoftpot);
Serial.println("Buttons:");
Serial.println(button1);
Serial.println(button2);
Serial.println(button3);
Serial.println(button4);
Serial.println(button5);
Serial.println(atrig);
u8x8.setFont(u8x8_font_7x14B_1x2_f);
u8x8.drawString(0,0,"Hello World!");
u8x8.drawString(0,50,"Hello World2!");
delay(2000);
}
EDIT: i already found the issue! the display contstructor needs to be changed to:
Code:
U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE, /* clock=*/ 7, /* data=*/ 8);