-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #82, minimal timeout 10 ms for RTOS
- Loading branch information
1 parent
775ac76
commit 11755d1
Showing
5 changed files
with
108 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// FILE: ADS_read_getError.ino | ||
// AUTHOR: Rob.Tillaart | ||
// PURPOSE: read analog inputs and check for error. | ||
// URL: https://github.com/RobTillaart/ADS1X15 | ||
|
||
// test | ||
// connect 1 potmeter per port. | ||
// | ||
// GND ---[ x ]------ 5V | ||
// | | ||
// | ||
// measure at x (connect to AIN0). | ||
|
||
|
||
#include "ADS1X15.h" | ||
|
||
ADS1115 ADS(0x48); | ||
|
||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
Serial.println(); | ||
Serial.println(__FILE__); | ||
Serial.print("ADS1X15_LIB_VERSION: "); | ||
Serial.println(ADS1X15_LIB_VERSION); | ||
Serial.println(); | ||
|
||
Wire.begin(); | ||
ADS.begin(); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
ADS.setGain(0); | ||
|
||
int16_t val_0 = ADS.readADC(0); | ||
int err = ADS.getError(); | ||
if (err != ADS1X15_OK) | ||
{ | ||
Serial.print("input 0 => "); | ||
Serial.println(err); | ||
} | ||
int16_t val_1 = ADS.readADC(1); | ||
err = ADS.getError(); | ||
if (err != ADS1X15_OK) | ||
{ | ||
Serial.print("input 1 => "); | ||
Serial.println(err); | ||
} | ||
int16_t val_2 = ADS.readADC(2); | ||
err = ADS.getError(); | ||
if (err != ADS1X15_OK) | ||
{ | ||
Serial.print("input 2 => "); | ||
Serial.println(err); | ||
} | ||
int16_t val_3 = ADS.readADC(3); | ||
err = ADS.getError(); | ||
if (err != ADS1X15_OK) | ||
{ | ||
Serial.print("input 3 => "); | ||
Serial.println(err); | ||
} | ||
|
||
float f = ADS.toVoltage(1); // voltage factor | ||
|
||
Serial.print("\tAnalog0: "); Serial.print(val_0); Serial.print('\t'); Serial.println(val_0 * f, 3); | ||
Serial.print("\tAnalog1: "); Serial.print(val_1); Serial.print('\t'); Serial.println(val_1 * f, 3); | ||
Serial.print("\tAnalog2: "); Serial.print(val_2); Serial.print('\t'); Serial.println(val_2 * f, 3); | ||
Serial.print("\tAnalog3: "); Serial.print(val_3); Serial.print('\t'); Serial.println(val_3 * f, 3); | ||
Serial.println(); | ||
|
||
delay(1000); | ||
} | ||
|
||
|
||
// -- END OF FILE -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters