#include "INHK_Pot3.h"
#include "Wave.h"
Potentiometer pot1(A0);
Potentiometer pot2(A1);
Potentiometer pot3(A2);
Potentiometer pot4(A3);
Potentiometer pot5(A4);
Potentiometer pot6(A5);
Wave carrierWave;
Wave modulatorWave1;
Wave modulatorWave2;
// int carrier_amplitude;
// float carrier_frequency;
// int carrier_offset = 0;
int mod1_amplitude;
float mod1_frequency;
int mod1_offset = 0;
int mod2_amplitude;
float mod2_frequency;
int mod2_offset = 0;
float resultingWave; // resulting wave; check data type return
float minValue = 0;
float maxValue = 255;
void setup() {
Serial.begin(115200); // Initialize serial communication
}
void loop() {
// carrier_amplitude = pot1.readValue(); // use this to control amplitude with pot
// carrier_frequency = pot2.readValue(); // use this to control frequency with pot
// carrier_offset = pot3.readValue(); // use this to control offset with pot
// carrierWave.setAmplitude(carrier_amplitude); // updates amplitude with pot reading
// carrierWave.setFrequency(carrier_frequency); // updates frequency with pot reading, use only with sine,saw,upSaw and triangle waves
// carrierWave.setSquareWaveFrequency(carrier_frequency); // updates frequency with pot reading, use only with square and bit waves
// carrierWave.setSquareWaveFrequency2(carrier_frequency); // updates frequency2 with pot reading, use only with square and bit waves
// carrierWave.setOffset(carrier_offset); // updates offset with pot reading
mod1_amplitude = pot1.readValue();
mod1_frequency = pot2.readValue();
mod1_offset = pot3.readValue();
modulatorWave1.setAmplitude(mod1_amplitude);
modulatorWave1.setFrequency(mod1_frequency); // updates frequency with pot reading, use only with sine,saw,upSaw and triangle waves
// modulatorWave1.setSquareWaveFrequency(mod1_frequency); // updates frequency with pot reading, use only with square and bit waves
// modulatorWave1.setSquareWaveFrequency2(mod1_frequency); // updates frequency2 with pot reading, use only with square and bit waves
modulatorWave1.setOffset(mod1_offset);
mod2_amplitude = pot4.readValue();
mod2_frequency = pot5.readValue();
mod2_offset = pot6.readValue();
modulatorWave2.setAmplitude(mod2_amplitude);
modulatorWave2.setFrequency(mod2_frequency); // updates frequency with pot reading, use only with sine,saw,upSaw and triangle waves
// modulatorWave2.setSquareWaveFrequency(mod2_frequency); // updates frequency with pot reading, use only with square and bit waves
// modulatorWave2.setSquareWaveFrequency2(mod2_frequency); // updates frequency2 with pot reading, use only with square and bit waves
modulatorWave2.setOffset(mod2_offset);
auto carrier = carrierWave.sineValue();
auto modulator1 = modulatorWave1.sineValue(); //0b10001010
auto modulator2 = modulatorWave2.triangleValue();
// resultingWave = (carrier + modulator1); // resulting wave, adjust as needed; check data type return
resultingWave = (carrier + modulator1 + modulator2); // resulting wave, adjust as needed; check data type return
if (resultingWave < minValue) {
minValue = resultingWave;
}
else if (resultingWave > maxValue){
maxValue = resultingWave;
}
uint8_t displayValue = map(resultingWave, minValue, maxValue, 0, 255);
// Serial.print("Carrier Wave: ");
// Serial.print(carrier);
// Serial.print(" , ");
// Serial.print("modulator1: ");
// Serial.print(modulator1);
// Serial.print(" , ");
// Serial.print("modulator2: ");
// Serial.print(modulator2);
// Serial.print(" , ");
// Serial.print("resultingWave: ");
// Serial.print(resultingWave);
// Serial.print(" , ");
Serial.print("displayValue: ");
Serial.print(displayValue);
Serial.println();
}