A simple sine wave generator library for Arduino.
- Generates sine wave values based on frequency, amplitude, and phase
- Provides methods for setting and getting frequency, amplitude, and phase values
- Provides a
getValue()
method that returns the current sine wave value based on the current time - Provides a
mapFloat
method that maps a value from one range to another.
WaveCraft(float frequency, float amplitude, float phase = 0)
: constructor that sets the frequency, amplitude, and phase of the wave.void setAmplitude(float amplitude)
: sets the amplitude of the wavevoid setFrequency(float frequency)
: sets the frequency of the wavevoid setPhase(float phase)
: sets the phase of the wavevoid setLow(float low)
: sets the minimum output valuevoid setHigh(float high)
: sets the maximum output valuefloat getLow()
: returns the minimum output valuefloat getHigh()
: returns the maximum output valuefloat mapFloat(float x, float in_min, float in_max, float out_min, float out_max)
: maps a value from one range to anotherfloat getValue()
: returns the current value of the sine wavefloat getIntValue()
: returns the current value of the sine wave as an int
- Download the WaveCraft library and add it to your Arduino libraries directory
- Include the WaveCraft.h header in your sketch
- Create a WaveCraft object and set the desired frequency, amplitude, and phase values
- Use the
getValue()
method to get the current sine wave value