Hallo,
I am looking for the electric diagram of
the simple sinus wave generator .
Used a pro mini board.
simpel sin generator
int speakerPin = 13; // pin number at which the LED is connected
const int analogInPin = A5; // pin number at which the potentiometer is connected
float sinVal; // variable which can hold the sine value
int pwmOut; // variable which can hold the analog value to be written to the analog output pin
unsigned int potValue = 0; // variable which can hold the analog input value
void setup()
{
pinMode(speakerPin, OUTPUT); // making the led pin as output
attachInterrupt(0, sine_wave, RISING); // enable the external interrupt 0, with function 'glow' as ISR and interrupt occurs on rising edge
tone(speakerPin, 2); // generating a tone initially with a frequency of 1 Hz
}
void loop()
{
potValue = analogRead(analogInPin) * 3; // read the analog value and scale - change to suit
tone(speakerPin, potValue);
}
//====================== ISR ===========================//
void sine_wave()
{
static int x = 0;
x ++;
//== generatingh the next sine value ==//
sinVal = (sin(radians(x)));
pwmOut = int(sinVal*255);
//== generatingh the next sine value ==//
analogWrite(speakerPin, pwmOut); // writing sine value to the output pin
if (x == 180)
x = 0;
else;
noTone(8);
}
thanks
Bouke