Using the ADG729 breakout with Arduino involves wiring up the breakout to your Arduino-compatible microcontroller, installing the Adafruit_ADG72x library, and running the provided example code.
Wiring
Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the board's VIN.
Here is an Adafruit Metro wired up to the breakout using the STEMMA QT connector. You'll connect your external analog input to 1A and 1B:
-
Board 5V to switch VIN (red wire)
-
Board GND to switch GND (black wire)
-
Board SCL to switch SCL (yellow wire)
- Board SDA to switch SDA (blue wire)
- Board A0 to switch DA (purple wire)
- Board A1 to switch DB (pink wire)
- Analog signal to switch 1A (orange wire) and switch 1B (green wire)
Make sure to share all grounds between the incoming analog signals and the circuit.
Here is an Adafruit Metro wired up using a solderless breadboard:
-
Board 5V to switch VIN (red wire)
-
Board GND to switch GND (black wire)
-
Board SCL to switch SCL (yellow wire)
- Board SDA to switch SDA (blue wire)
- Board A0 to switch DA (purple wire)
- Board A1 to switch DB (pink wire)
- Analog signal to switch 1A (orange wire) and switch 1B (green wire)
Make sure to share all grounds between the incoming analog signals and the circuit.
Library Installation
You can install the Adafruit_ADG72x library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit_ADG72x, and select the Adafruit ADG72x library:
If asked about dependencies, click "Install all".
If the dependencies are already installed, you must make sure you update them through the Arduino Library Manager before loading the example!
// SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries // // SPDX-License-Identifier: MIT #include <Adafruit_ADG72x.h> Adafruit_ADG72x adg72x; int analogInA0 = A0; int analogInA1 = A1; int analogValueDA = 0; int analogValueDB = 0; unsigned long switchTimer = 1000; // 1000 ms = 1 second for channel switch unsigned long readTimer = 10; // 10 ms for analog read unsigned long lastSwitchTime = 0; // Last time the channels were switched unsigned long lastReadTime = 0; // Last time the analog was read uint8_t currentChannel = 0; // Current channel being selected void setup() { Serial.begin(115200); // Wait for serial port to open while (!Serial) { delay(1); } // Try with the ADG728 default address first... if (adg72x.begin(ADG728_DEFAULT_ADDR, &Wire)) { //Serial.println("ADG728 found!"); } // Maybe they have an ADG729? else if (adg72x.begin(ADG729_DEFAULT_ADDR, &Wire)) { //Serial.println("ADG729 found!"); } else { Serial.println("No ADG72x device found? Check wiring!"); while (1); // Stop here if no device was found } } void loop() { unsigned long currentTime = millis(); // read and print analog value every 10ms if ((currentTime - lastReadTime) >= readTimer) { analogValueDA = analogRead(analogInA0); analogValueDB = analogRead(analogInA1); Serial.print(analogValueDA); Serial.print(","); Serial.println(analogValueDB); lastReadTime = currentTime; } // switch channels every 1 second if ((currentTime - lastSwitchTime) >= switchTimer) { uint8_t bits = 1 << currentChannel; // Shift a '1' from LSB to MSB if (!adg72x.selectChannels(bits)) { Serial.println("Failed to set channels..."); } /*Serial.print((currentChannel % 4) + 1); if (currentChannel < 4) Serial.println("A"); else Serial.println("B");*/ currentChannel = (currentChannel + 1) % 8; // Move to the next channel, wrap around at 8 lastSwitchTime = currentTime; } }
Upload the sketch to your board and open up the Serial Plotter (Tools -> Serial Plotter) at 115200 baud. You'll see the analog data printed to the plotter. Every two seconds, the ADG729 switches channels being sent to pins DA and DB. In the .GIF below, you'll see analog signals on channel 1 (1A and 1B) being read from pin DA to board pin A0 and pin DB to board pin A1 as their channels are turned on.
Page last edited January 21, 2025
Text editor powered by tinymce.