#include "INHK_Pot3.h"
Potentiometer pot1(A0);
Potentiometer pot2(A1);
// amplitude = pot1.readValue();
// frequency = (pot2.readValue() / 1000);
int amplitude = 100; // Amplitude of the sine wave max 255, but offset needs to follow
float frequency = 0.001; // Frequency of the sine wave - try value bewteewn 0.5 and 0.001
const int offset = 127; // Offset to ensure the sine wave is always positive
const uint8_t updateInterval = 20; // Update interval in milliseconds
float angle = 0; // Angle in radians
unsigned long previousMillis = 0; // Stores the last time the sine value was updated
void setup() {
Serial.begin(9600); // Initialize serial communication
}
void loop() {
// Get the current time
unsigned long currentMillis = millis();
// Check if it's time to update the sine wave value
if (currentMillis - previousMillis >= updateInterval) {
// Save the last time you updated the sine value
previousMillis = currentMillis;
// Calculate the sine wave value
float sineValue = amplitude * sin(angle) + offset;
// Print the sine wave value to the serial monitor
Serial.println(sineValue);
// Increment the angle
angle += frequency;
// Wrap the angle to stay within 0 to 2*PI range
if (angle >= TWO_PI) {
angle -= TWO_PI;
}
}
// Other non-blocking code can be placed here
}