Created
December 2, 2016 12:33
-
-
Save nadavmatalon/6ff61f190d34e4efef129c19ac8b9157 to your computer and use it in GitHub Desktop.
MCP3221 Basic Usage
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
#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