Add multiple AW9323

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ICortez27
 
Posts: 13
Joined: Thu Aug 05, 2021 11:25 pm

Add multiple AW9323

Post by ICortez27 »

Hi!
I can't find in the documentation how to declare and use more than one AW9523. I've seen how to change the address with the jumper on the back of the board, but not how to set them up in code (arduino). In the example code the only place I see the address been called is in:

Code: Select all


  if (! aw.begin(0x58)) {
    Serial.println("AW9523 not found? Check wiring!");
    while (1) delay(10);  // halt forever
  }
So it is just a matter of adding:

Code: Select all

Adafruit_AW9523 aw;
Adafruit_AW9523 aw2;
And something like this in the Setup section?

Code: Select all

  if (! aw.begin(0x58)) {
    Serial.println("AW9523 not found? Check wiring!");
    while (1) delay(10);  // halt forever
  }

  if (! aw2.begin(0x59)) {
    Serial.println("AW9523_2 not found? Check wiring!");
    while (1) delay(10);  // halt forever
  }
Thank you!

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Add multiple AW9323

Post by dastels »

That should do it.

Dave

User avatar
ICortez27
 
Posts: 13
Joined: Thu Aug 05, 2021 11:25 pm

Re: Add multiple AW9323

Post by ICortez27 »

Thank you for the reply. I still can't get the second AW9523 to be detected. A0 jumper is soldered and SCL,SDA,Vin and Grd are connected just like the first AW9523.

Code: Select all

#include <Adafruit_AW9523.h>

Adafruit_AW9523 aw;
Adafruit_AW9523 aw2;

uint8_t LedAWPin = 0;
uint8_t ButtonAWPin1 = 1;
uint8_t ButtonAWPin2 = 2;

uint8_t LedAW2Pin = 0;
uint8_t ButtonAW2Pin1 = 1;
uint8_t ButtonAW2Pin2 = 2;


void setup() {
  delay(500);
  Serial.begin(9600);
  while (!Serial) delay(1);  // wait for serial port to open
  
  Serial.println("Adafruit AW9523 Button + LED test!");

  if (! aw.begin(0x58)) {
    Serial.println("AW9523_0 not found? Check wiring!");
    while (1) delay(10);  // halt forever
  }

  if (! aw2.begin(0x59)) {
    Serial.println("AW9523_2 not found? Check wiring!");
    while (1) delay(10);  // halt forever
  }


  Serial.println("AW9523 found!");
  aw.pinMode(LedAWPin, OUTPUT); 
  aw.pinMode(ButtonAWPin1, INPUT);
  aw.enableInterrupt(ButtonAWPin1, true);
  aw.pinMode(ButtonAWPin2, INPUT);
  aw.enableInterrupt(ButtonAWPin2, true);

  aw2.pinMode(LedAW2Pin, OUTPUT); 
  aw2.pinMode(ButtonAW2Pin1, INPUT);
  aw2.enableInterrupt(ButtonAW2Pin1, true);
  aw2.pinMode(ButtonAW2Pin2, INPUT);
  aw2.enableInterrupt(ButtonAW2Pin2, true);  
}


void loop() {

aw.analogWrite(LedAWPin, 200);
if (aw.digitalRead(ButtonAWPin1)==0){
Serial.println("AW_Bouton1"); 
aw.analogWrite(LedAWPin, 0); 
}
if (aw.digitalRead(ButtonAWPin2)==0){
Serial.println("AW_Bouton2");  

aw2.analogWrite(LedAW2Pin, 0); 
}
aw2.analogWrite(LedAW2Pin, 200);
if (aw.digitalRead(ButtonAW2Pin1)==0){
Serial.println("AW2_Bouton1"); 
aw2.analogWrite(LedAW2Pin, 0); 
}
if (aw.digitalRead(ButtonAW2Pin2)==0){
Serial.println("AW2_Bouton2");  
aw2.analogWrite(LedAW2Pin, 0); 
}

  delay(10);
}

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Add multiple AW9323

Post by dastels »

So it locks up with "AW9523_2 not found"?

How are you connecting them? And to what?

Dave

User avatar
ICortez27
 
Posts: 13
Joined: Thu Aug 05, 2021 11:25 pm

Re: Add multiple AW9323

Post by ICortez27 »

Yes, it locks at "AW9523_2 not found". I connected the second one with test hook clips. I’m using a Teensy 4.0. First one have headers.
Teensy pin 18 to SDA (AW9523_0 and AW9523_2)
Teensy pin 19 to SCL (AW9523_0 and AW9523_2)
Teensy 3v to Vin (AW9523_0 and AW9523_2)
Teensy Gnd to Gnd (AW9523_0 and AW9523_2)

AW9523_2 Has power (green Led is on).

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Add multiple AW9323

Post by dastels »

Test hooks won't give you a reliable connection. Solder them or use the STEMMA-QT connections.

Dave

User avatar
ICortez27
 
Posts: 13
Joined: Thu Aug 05, 2021 11:25 pm

Re: Add multiple AW9323

Post by ICortez27 »

Yeah, you were right, connection reliability was the issue. I was able to get the code running and connect to both AW9523s. Thank you again for the support!

User avatar
ICortez27
 
Posts: 13
Joined: Thu Aug 05, 2021 11:25 pm

Re: Add multiple AW9323

Post by ICortez27 »

Another question related to using multiple AW9523. For my project, I’m planning on using 4 AW9523 to run 8 Leds and 8 button on each board. I’m concerned about powering those from the microcontroller (Teensy 4.0) 3.3v(250mA max) pin. Is it safe to do so? I’ve test 2 boards and it was running just fine, but I don’t want to damage the teensy or the AW9523 boards. I will power the project with a lipo battery or 3xAA batteries.
Thank you

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Add multiple AW9323

Post by dastels »

The AW9323 gives you the ability to control the current through each LED, so you can keep it low... how low depends on how bright you need them. But you'll probably need to power them separately from the Teensy.

I'd start by figuring out how much current you need for the LEDs and scale that up by the number of LEDs you need (32, I believe). You won't necessarily need multiple batteries, but possibly just multiple regulators.

Dave

User avatar
ICortez27
 
Posts: 13
Joined: Thu Aug 05, 2021 11:25 pm

Re: Add multiple AW9323

Post by ICortez27 »

So assuming that the leds have a forward current of 20mA, for the worst case scenario with all leds at full brightness (255) 20mA x 32=640mA. I was planning to reduce brightness by a little less than half (60%) so (20x0.60)x32=384mA.
I’m not too familiar with regulators. Should one for the teensy and one for the 4 AW9523 is enough, assuming it can output at least 384mA? Like this one https://www.adafruit.com/product/2165.

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Add multiple AW9323

Post by dastels »

That regulator will give up up to 800mA and will be fine for the LEDs. You'll also need to supply the regulator with the amount of current you want to get out of it.

Dave

User avatar
ICortez27
 
Posts: 13
Joined: Thu Aug 05, 2021 11:25 pm

Re: Add multiple AW9323

Post by ICortez27 »

For the connection, should I connect:
  • Battery V+ to Micro Controller Vin
  • Battery V+ to Regulator Vin and Vout to the AW9523

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Add multiple AW9323

Post by dastels »

Yes, and ALL grounds connected together and to battery V-.

Dave

User avatar
ICortez27
 
Posts: 13
Joined: Thu Aug 05, 2021 11:25 pm

Re: Add multiple AW9323

Post by ICortez27 »

Thank you very much for the support!

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”