GY-63_MS5611/libraries/MCP_ADC/examples/MCP3008_deltaRead/MCP3008_deltaRead.ino

62 lines
1.1 KiB
Arduino
Raw Normal View History

2021-01-29 06:31:58 -05:00
//
// FILE: MCP3008_deltaRead.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo
// DATE: 2020-08-13
2021-12-21 09:31:31 -05:00
2021-01-29 06:31:58 -05:00
#include "MCP_ADC.h"
2023-08-16 04:07:24 -04:00
MCP3008 mcp1; // use HWSPI
MCP3004 mcp2(6, 7); // use SWSPI
2021-01-29 06:31:58 -05:00
2021-12-21 09:31:31 -05:00
2021-01-29 06:31:58 -05:00
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
2023-08-16 04:07:24 -04:00
Serial.print("MCP_ADC_LIB_VERSION: ");
Serial.println(MCP_ADC_LIB_VERSION);
2021-01-29 06:31:58 -05:00
mcp1.begin(10);
mcp2.begin(5);
Serial.println();
Serial.println("ADC\tCHAN\tMAXVALUE");
Serial.print("mcp1\t");
Serial.print(mcp1.channels());
Serial.print("\t");
Serial.println(mcp1.maxValue());
Serial.print("mcp2\t");
Serial.print(mcp2.channels());
Serial.print("\t");
Serial.println(mcp2.maxValue());
}
2021-12-21 09:31:31 -05:00
2021-01-29 06:31:58 -05:00
void loop()
{
Serial.print("mcp1:\t");
for (int channel = 0 ; channel < mcp1.channels(); channel++)
{
int val = mcp1.deltaRead(channel);
Serial.print(val);
Serial.print("\t");
}
Serial.println();
Serial.print("mcp2:\t");
for (int channel = 0 ; channel < mcp2.channels(); channel++)
{
int val = mcp2.deltaRead(channel);
Serial.print(val);
Serial.print("\t");
}
Serial.println();
delay(1000);
}
2021-12-21 09:31:31 -05:00
2023-08-16 04:07:24 -04:00
// -- END OF FILE --
2021-12-21 09:31:31 -05:00