#include const int ds_address = 0xB0 >> 1; //DS1077 default address const byte freq_pin = 7; //read frequency on this pin void setup() { Wire.begin(); Serial.begin(9600); pinMode(freq_pin, INPUT); // the line below writes to the MUX register // see the app note for clarifying this value //i2c_write(ds_address, 0x02, 0xF9, 0x00); // the line below writes to the DIV register // the bits valued at 987 are the hex values // taken from the DS1077 REG spread sheet //i2c_write(ds_address, 0x01, 0x98, 0x70); } void loop() { // read the frequency Serial.println(getFrequency(freq_pin)); } void i2c_write(int device, byte address) { Wire.beginTransmission(device); //start transmission to device Wire.write(address); // send register address Wire.endTransmission(); //end transmission } void i2c_write(int device, byte address, byte val1) { Wire.beginTransmission(device); //start transmission to device Wire.write(address); // send register address Wire.write(val1); // send value to write Wire.endTransmission(); //end transmission } void i2c_write(int device, byte address, byte val1, byte val2) { Wire.beginTransmission(device); //start transmission to device Wire.write(address); // send register address Wire.write(val1); // send value to write Wire.write(val2); // send value to write Wire.endTransmission(); //end transmission } long getFrequency(int pin) { #define SAMPLES 4096 long freq = 0; for(unsigned int j=0; j