File tree Expand file tree Collapse file tree 2 files changed +83
-0
lines changed Expand file tree Collapse file tree 2 files changed +83
-0
lines changed Original file line number Diff line number Diff line change 1+ // SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
2+ //
3+ // SPDX-License-Identifier: MIT
4+
5+ #include < Adafruit_ADG72x.h>
6+
7+ Adafruit_ADG72x adg72x;
8+
9+ bool isADG728 = false ; // which chip are we connected to?
10+
11+ int analogIn = A0;
12+ int analogValue = 0 ;
13+ unsigned long timer = 2000 ;
14+ unsigned long startTime = millis();
15+
16+ void setup () {
17+ Serial.begin (115200 );
18+
19+ // Wait for serial port to open
20+ while (!Serial) {
21+ delay (1 );
22+ }
23+
24+ // Try with the ADG728 default address first...
25+ if (adg72x.begin (ADG728_DEFAULT_ADDR, &Wire)) {
26+ Serial.println (" ADG728 found!" );
27+ isADG728 = true ;
28+ }
29+ // Maybe they have an ADG729?
30+ else if (adg72x.begin (ADG729_DEFAULT_ADDR, &Wire)) {
31+ Serial.println (" ADG729 found!" );
32+ isADG728 = false ;
33+ }
34+ else {
35+ Serial.println (" No ADG device found? Check wiring!" );
36+ while (1 ); // Stop here if no device was found
37+ }
38+ }
39+
40+ void loop () {
41+ analogValue = analogRead (analogIn);
42+ Serial.println (analogValue);
43+
44+ if ((millis () - startTime) >= timer) {
45+ for (uint8_t i = 0 ; i < 8 ; i++) {
46+ if (isADG728) {
47+ } else {
48+ if (i < 4 ) Serial.println (" A" );
49+ else Serial.println (" B" );
50+ }
51+ uint8_t bits = 1 << i; // Shift a '1' from LSB to MSB
52+ if (!adg72x.selectChannels (bits)) {
53+ }
54+ startTime = millis ();
55+ }
56+ }
57+ delay (10 );
58+ }
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: Copyright (c) 2024 Liz Clark for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: MIT
4+
5+ import time
6+ import board
7+ import adafruit_adg72x
8+ from analogio import AnalogIn
9+
10+ analog_in = AnalogIn (board .A0 )
11+
12+ i2c = board .I2C ()
13+ switch = adafruit_adg72x .ADG72x (i2c )
14+
15+ c = 0
16+ switch_time = 2
17+ clock = time .monotonic ()
18+ while True :
19+ if (time .monotonic () - clock ) > switch_time :
20+ print (f"Selecting channel { c + 1 } " )
21+ switch .channel = c
22+ c = (c + 1 ) % 8
23+ clock = time .monotonic ()
24+ print ((analog_in .value ,))
25+ time .sleep (0.1 )
You can’t perform that action at this time.
0 commit comments