File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
examples/Advanced/ADC_Dual_Mode Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < Arduino_AdvancedAnalog.h>
2
+
3
+ AdvancedADC adc1 (A0, A1);
4
+ AdvancedADC adc2 (A2, A3);
5
+ AdvancedADCDual adc_dual (adc1, adc2);
6
+ uint64_t last_millis = 0 ;
7
+
8
+ void setup () {
9
+ Serial.begin (9600 );
10
+ while (!Serial) {
11
+ }
12
+
13
+ // Resolution, sample rate, number of samples per channel, queue depth.
14
+ if (!adc_dual.begin (AN_RESOLUTION_16, 16000 , 32 , 32 )) {
15
+ Serial.println (" Failed to start analog acquisition!" );
16
+ while (1 );
17
+ }
18
+ }
19
+
20
+ void loop () {
21
+ if (adc1.available ()) {
22
+ SampleBuffer buf1 = adc1.read ();
23
+ SampleBuffer buf2 = adc2.read ();
24
+
25
+ // Process the buffer.
26
+ if (millis () - last_millis > 1 ) {
27
+ Serial.println (buf1.timestamp ()); // Print buffer timestamp
28
+ Serial.println (buf1[0 ]); // Print sample from first channel
29
+ Serial.println (buf1[1 ]); // Print sample from second channel
30
+
31
+ Serial.println (buf2.timestamp ()); // Print buffer timestamp
32
+ Serial.println (buf2[0 ]); // Print sample from first channel
33
+ Serial.println (buf2[1 ]); // Print sample from second channel
34
+
35
+ last_millis = millis ();
36
+ }
37
+
38
+ // Release the buffer to return it to the pool.
39
+ buf1.release ();
40
+ buf2.release ();
41
+ }
42
+ }
You can’t perform that action at this time.
0 commit comments