mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
54 lines
776 B
C++
54 lines
776 B
C++
//
|
|
// FILE: ADS_minimum.ino
|
|
// AUTHOR: Rob.Tillaart
|
|
// VERSION: 0.1.0
|
|
// PURPOSE: read analog input
|
|
//
|
|
|
|
// test
|
|
// connect 1 potmeter
|
|
//
|
|
// GND ---[ x ]------ 5V
|
|
// |
|
|
//
|
|
// measure at x (connect to AIN0).
|
|
|
|
// view with Serial Plotter
|
|
|
|
|
|
#include "ADS1X15.h"
|
|
|
|
|
|
// choose you sensor
|
|
// ADS1013 ADS(0x48);
|
|
// ADS1014 ADS(0x48);
|
|
// ADS1015 ADS(0x48);
|
|
// ADS1113 ADS(0x48);
|
|
// ADS1114 ADS(0x48);
|
|
|
|
ADS1115 ADS(0x48);
|
|
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(115200);
|
|
Serial.println(__FILE__);
|
|
Serial.print("ADS1X15_LIB_VERSION: ");
|
|
Serial.println(ADS1X15_LIB_VERSION);
|
|
|
|
ADS.begin();
|
|
ADS.setGain(0); // 6.144 volt
|
|
Serial.println("Voltage");
|
|
}
|
|
|
|
|
|
void loop()
|
|
{
|
|
int16_t raw = ADS.readADC(0);
|
|
Serial.println(ADS.toVoltage(raw), 3);
|
|
}
|
|
|
|
|
|
// -- END OF FILE --
|
|
|