Skip to content

Class Instantiation

Arnd edited this page Dec 11, 2020 · 4 revisions

The MCP7940 class has no parameters. It uses I2C where the 2 pins are predefined and the MCP7940 has a fixed I2C address. Instantiating the class does not check to see if the MCP7940 is present, that is done as part of the begin() method.


Example:

MCP7940_Class MCP7940; // Create an instance of the MCP7940
...
void setup() {
  Serial.begin(SERIAL_SPEED);
  while (!MCP7940.begin()) { // Initialize RTC communications
    Serial.println("Unable to find MCP7940. Checking again in 3 seconds.");
    delay(3000);
  } // of loop until device is located
...
} // of setup
Clone this wiki locally