Here is code I have found for generating a triangle wave using the library. What is the additional code you would need to print out the triangle wave on the serial monitor? Not much point in generating a triangle wave on pin 9 if you can't see it or use it.
I have no idea how to use the hyperlink or anything else to show you the entire article that discusses how to get a triangle wave. So I am just showing the code.
#include <FunctionGenerator.h>
FunctionGenerator waveform;
void setup() {
// Initialize the waveform object
waveform.begin();
// Set the output pin (e.g., digital pin 9)
waveform.setOutputPin(9);
// Set the frequency (e.g., 1000 Hz)
waveform.setFrequency(1000);
// Set the amplitude (e.g., 50% duty cycle)
waveform.setAmplitude(0.5);
// Set the waveform type to triangle
waveform.setWaveformType(TRIANGLE);
}
void loop() {
// Start generating the triangle wave
waveform.start();
delay(5000); // Wait for 5 seconds
// You can optionally stop the waveform generation
// waveform.stop();
}
t#include <FunctionGenerator.h>
FunctionGenerator waveform;
void setup() {
// Initialize the waveform object
waveform.begin();
// Set the output pin (e.g., digital pin 9)
waveform.setOutputPin(9);
// Set the frequency (e.g., 1000 Hz)
waveform.setFrequency(1000);
// Set the amplitude (e.g., 50% duty cycle)
waveform.setAmplitude(0.5);
// Set the waveform type to triangle
waveform.setWaveformType(TRIANGLE);
}
void loop() {
// Start generating the triangle wave
waveform.start();
delay(5000); // Wait for 5 seconds
// You can optionally stop the waveform generation
// waveform.stop();
}ype or paste code here