#include <Wire.h>
#include "MCP3X21.h"
const uint8_t address = 0x4D;
const uint16_t ref_voltage = 3300; // in mV
MCP3021 mcp3021(address);
void setup() {
Serial.begin(115200);
#if defined(ESP8266)
Wire.begin(SDA, SCL);
mcp3021.init(&Wire);
#else
mcp3021.init();
#endif
}
void loop() {
uint16_t result = mcp3021.read();
Serial.print(F("ADC: "));
Serial.print(result);
Serial.print(F(", mV: "));
Serial.println(mcp3021.toVoltage(result, ref_voltage));
delay(1000);
}
-
Notifications
You must be signed in to change notification settings - Fork 6
Arduino library for MCP3021 I2C ADC
License
pilotak/MCP3X21
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Arduino library for MCP3021 I2C ADC
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published