Skip to content

Commit a13dd6b

Browse files
author
microbuilder
committed
Simple ADC example
1 parent 70ed05b commit a13dd6b

File tree

1 file changed

+20
-0
lines changed
  • libraries/AdafruitFeather52Examples/Hardware/adc

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
int adcin = A5;
2+
int adcvalue = 0;
3+
float mv_per_lsb = 3600.0F/1024.0F; // 10-bit ADC with 3.6V input range
4+
5+
void setup() {
6+
Serial.begin(115200);
7+
}
8+
9+
void loop() {
10+
// Get a fresh ADC value
11+
adcvalue = analogRead(adcin);
12+
13+
// Display the results
14+
Serial.print(adcvalue);
15+
Serial.print(" [");
16+
Serial.print((float)adcvalue * mv_per_lsb);
17+
Serial.println(" mV]");
18+
19+
delay(100);
20+
}

0 commit comments

Comments
 (0)