How to use ads1115.

Dependencies:   ADS1015 USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
arve0
Date:
Sat Oct 11 08:57:10 2014 +0000
Parent:
0:ea70612a3ee1
Commit message:
hello world example

Changed in this revision

ADS1015.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ADS1015.lib	Sun Nov 10 18:30:09 2013 +0000
+++ b/ADS1015.lib	Sat Oct 11 08:57:10 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/arve0/code/ADS1015/#8174d9ceeca1
+http://mbed.org/users/arve0/code/ADS1015/#aa277517f0ad
--- a/main.cpp	Sun Nov 10 18:30:09 2013 +0000
+++ b/main.cpp	Sat Oct 11 08:57:10 2014 +0000
@@ -5,15 +5,18 @@
 #define SERIAL_BAUD_RATE    9600
 
 I2C i2c(p23, p18);
-Adafruit_ADS1015 ads(&i2c);
+Adafruit_ADS1115 ads(&i2c);
 USBSerial pc; // USB CDC serial port
 
- 
-int main() {
-    uint16_t reading;
+
+int main(){
+    ads.setGain(GAIN_SIXTEEN); // set range to +/-0.256V
+    int reading;
     while (1) {
         reading = ads.readADC_SingleEnded(0); // read channel 0
         pc.printf("reading: %d\r\n", reading); // print reading
         wait(2); // loop 2 sek
+        reading = ads.readADC_Differential_2_3(); // differential channel 2-3
+        pc.printf("diff a2, a3: %d\r\n", reading); // print diff
     }
 }
\ No newline at end of file