aboutsummaryrefslogtreecommitdiffstats
path: root/arduino/libraries/Bluefruit52Lib/examples/Hardware/adc/adc.ino
diff options
context:
space:
mode:
Diffstat (limited to 'arduino/libraries/Bluefruit52Lib/examples/Hardware/adc/adc.ino')
-rwxr-xr-xarduino/libraries/Bluefruit52Lib/examples/Hardware/adc/adc.ino21
1 files changed, 21 insertions, 0 deletions
diff --git a/arduino/libraries/Bluefruit52Lib/examples/Hardware/adc/adc.ino b/arduino/libraries/Bluefruit52Lib/examples/Hardware/adc/adc.ino
new file mode 100755
index 0000000..1133826
--- /dev/null
+++ b/arduino/libraries/Bluefruit52Lib/examples/Hardware/adc/adc.ino
@@ -0,0 +1,21 @@
+int adcin = A5;
+int adcvalue = 0;
+float mv_per_lsb = 3600.0F/1024.0F; // 10-bit ADC with 3.6V input range
+
+void setup() {
+ Serial.begin(115200);
+ while ( !Serial ) delay(10); // for nrf52840 with native usb
+}
+
+void loop() {
+ // Get a fresh ADC value
+ adcvalue = analogRead(adcin);
+
+ // Display the results
+ Serial.print(adcvalue);
+ Serial.print(" [");
+ Serial.print((float)adcvalue * mv_per_lsb);
+ Serial.println(" mV]");
+
+ delay(100);
+}