diff options
author | Wolfgang (Wolle) Ewald <wolfgang.ewald@wolles-elektronikkiste.de> | 2020-08-04 18:58:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-04 18:58:56 +0200 |
commit | 73e9078f2c16a4c33929699fa202a7248100a00f (patch) | |
tree | 76937c55ef0f7faae1fdfd52381e278eab4abe38 | |
parent | Create Experimental_getResultWithRange.ino (diff) | |
download | ADS1115_WE-73e9078f2c16a4c33929699fa202a7248100a00f.tar ADS1115_WE-73e9078f2c16a4c33929699fa202a7248100a00f.tar.gz ADS1115_WE-73e9078f2c16a4c33929699fa202a7248100a00f.tar.bz2 ADS1115_WE-73e9078f2c16a4c33929699fa202a7248100a00f.tar.lz ADS1115_WE-73e9078f2c16a4c33929699fa202a7248100a00f.tar.xz ADS1115_WE-73e9078f2c16a4c33929699fa202a7248100a00f.tar.zst ADS1115_WE-73e9078f2c16a4c33929699fa202a7248100a00f.zip |
Diffstat (limited to '')
-rw-r--r-- | examples/Experimental_getResultWithRange/Experimental_getResultWithRange.ino | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/examples/Experimental_getResultWithRange/Experimental_getResultWithRange.ino b/examples/Experimental_getResultWithRange/Experimental_getResultWithRange.ino index 8b13789..6125b91 100644 --- a/examples/Experimental_getResultWithRange/Experimental_getResultWithRange.ino +++ b/examples/Experimental_getResultWithRange/Experimental_getResultWithRange.ino @@ -1 +1,46 @@ - +/***************************************************************************
+* Example sketch for the ADS1115_WE library
+*
+* This is an experimental sketch
+*
+* Further information can be found on:
+* https://wolles-elektronikkiste.de/ads1115
+*
+***************************************************************************/
+
+#include<ADS1115_WE.h>
+#include<Wire.h>
+#define I2C_ADDRESS 0x48
+
+ADS1115_WE adc(I2C_ADDRESS);
+// ADS1115_WE adc = ADS1115_WE(); // Alternative: uses default address 0x48
+
+void setup() {
+ Wire.begin();
+ Serial.begin(9600);
+ if(!adc.init()){
+ Serial.println("ADS1115 not connected!");
+ }
+
+ adc.setVoltageRange_mV(ADS1115_RANGE_1024); //comment line/change parameter to change range
+
+ adc.setCompareChannels(ADS1115_COMP_0_1); //comment line/change parameter to change channel
+
+ adc.setMeasureMode(ADS1115_CONTINUOUS); //comment line/change parameter to change mode
+
+ Serial.println("ADS1115 Example Sketch - Eperimental Sketch to test getResultWithRange");
+ Serial.println();
+}
+
+void loop() {
+ float voltage = 0.0;
+ int mappedResult = 0;
+ voltage = adc.getResult_mV(); // alternative: getResult_mV for Millivolt
+ mappedResult = adc.getResultWithRange(0, 255);
+ Serial.print("Channel 0 vs GND [mV]: ");
+ Serial.println(voltage);
+ Serial.print("Mapped Result : ");
+ Serial.println(mappedResult);
+ Serial.println("-------------------------------");
+ delay(2000);
+}
|