Skip to content

Instantly share code, notes, and snippets.

@nadavmatalon
Created December 2, 2016 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadavmatalon/6ff61f190d34e4efef129c19ac8b9157 to your computer and use it in GitHub Desktop.
Save nadavmatalon/6ff61f190d34e4efef129c19ac8b9157 to your computer and use it in GitHub Desktop.
MCP3221 Basic Usage
#include "MCP3221.h"
const byte DEV_ADDR = 0x4D; // I2C address of the MCP3221 (Change if needed)
MCP3221 mcp3221(DEV_ADDR); // constructs a new MCP3221 object with the relevant I2C address
void setup() {
Serial.begin(9600); // initiallizes the Serial Communications Port (at 9600bd)
Wire.begin(); // initiallizes the I2C Communications bus
while(!Serial); // waits for Serial Port to initialize
}
void loop() {
Serial.print(F("\nVoltage:\t\t"));
Serial.print(mcp3221.getVoltage());
Serial.print(F("mV\n\n"));
delay(750);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment