Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ADS1015_fast KXTJ3
Diff: ADS1115-hello_world/main.cpp
- Revision:
- 0:c0e44c46c573
- Child:
- 1:a8e61f3910ad
diff -r 000000000000 -r c0e44c46c573 ADS1115-hello_world/main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ADS1115-hello_world/main.cpp Mon Aug 28 10:16:59 2017 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#include "Adafruit_ADS1015.h"
+#include "USBSerial.h"
+#include "MPU6050.h"
+#define SERIAL_BAUD_RATE 115200
+
+MPU6050 ark(p9,p10);
+I2C i2c(p28, p27);
+Adafruit_ADS1115 ads0(&i2c, 0x48);
+Adafruit_ADS1115 ads1(&i2c, 0x49);
+//Adafruit_ADS1115 ads2(&i2c, 0x4A);
+Serial pc(USBTX, USBRX); // tx, rx
+Ticker sample;
+short read[8];
+int done;
+int j;
+int k;
+float acce[3];
+
+void read_adc()
+{
+ for (k = 0; k < 4; k = k + 1) {
+ read[k]= ads0.readADC_SingleEnded(k);
+ read[k+4]= ads1.readADC_SingleEnded(k);
+ }
+ ark.getAccelero(acce);
+ j = acce[0]*10;
+ pc.printf(",%d,%d,%d,%d,%d,%d,%d,%d,%d,\r\n", read[1], read[0], read[4], read[7], read[5], read[6], read[2], read[3],j); // print 'read' array to serial port
+ //pi.printf(",%d,%d,%d,%d,%d,%d,%d,%d,\r\n", read[1], read[0], read[4], read[7], read[5], read[6], read[2], read[3]); // print 'read' array to serial port
+}
+
+int main()
+{
+ i2c.frequency(400000);
+ pc.baud(115200);
+ //pi.baud(115200);
+ ads0.setGain(GAIN_ONE); // set range to +/-4.096V
+ ads1.setGain(GAIN_ONE); // set range to +/-4.096V
+ sample.attach_us(&read_adc, 100000);
+ while (1) {
+ wait_ms(101); // wait indefinitely because the ticker restarts every 50 ms
+ }
+}
\ No newline at end of file