circiut

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

noTone(8);

Cool! Read the How to use post, and that won't happen.

Why have you posted that code?
Is it supposed to create a sin wave output? It won't you know.
What have you got connected to pin 2 to force the generation of sin waves?

Why is that code writing a square wave tone to the speakerPin and writing a PWM duty cycle to the same pin?

What do you want to do? Yes generate a sin wave ( not sinus, that is in the nose Sinus ) but what frequency range do you want it to cover?

Hi.

Bouke (not Bob), is a Dutch name and zhtech has posted before mentioning his radio call name, internet provider and e-mail address from the Netherlands.
Sine in Dutch is sinus, so that's where that came from.

@zhtech: Being a radio amateur i would think you'd know what you would need to get closer to the waveform you want.
As Grumpy_Mike stated, you need to know (and / or provide) some more specifications if you need help to figure this out.

Being a radio amateur

Snap
de G8HBR