//Guitar frequency to 1V/Oct CV output. //Input signal via fundamental extractor and Schmitt trigger //Mick Bailey 2023 //Version 1.0 #include //Log(2) library #include Adafruit_MCP4725 MCP4725; int Htime; //integer for storing high time int Ltime; //integer for storing low time float Ttime; // integer for storing total time of a cycle float frequency; //storing frequency float mv_conversion; // frequency to voltage conversion int dac_value; void setup() { pinMode(8, INPUT); //guitar input pin 8 MCP4725.begin(0x60); // set the I2C Address of the MCP4725 } void loop() { Htime = pulseIn(8, HIGH); //read high time Ltime = pulseIn(8, LOW); //read low time Ttime = Htime + Ltime; //calculate total time frequency = 1000000 / Ttime; //calculate frequency mv_conversion = log2(frequency / 55) * 1000; //frequency to voltage in millivolts conversion dac_value = (mv_conversion / 5000) * 4095; // get DAC value as an integer MCP4725.setVoltage(dac_value, false); }