In this tutorial you will learn how to create sine signal from digital pulses using Arduino UNO. Sine wave signal is one important and fundamental signal. As such it is good to know how to generate sine wave signal for electronics application or other sciences experimentation.
One simple way to Create sine signal from digital pulses using Arduino is to use the digital pulses that can be generated using Arduino. It is likely that you already know how to generate digital pulses using Arduino. If you recall, the arduino digitalWrite function is used for this purpose. The delay between the high and low pulses is created using the delay function. The tutorial digitalRead and digitalWrite covers some basic of using digitalWrite function.
Now if this periodic digital signal is fed to a RC low pass filter then at the output of the filter you will get approximate sinusoidal signal. See the following circuit diagram.
As you can see we have connected the RC Low Pass Filter at the pin 9.The value of resistor is 318KOhm and value of capacitor is 1uF. We will explain how this values was calculated further down.
Now the following is the Arduino program code that generates the digital pulses of frequency of 0.5Hz.
const int LED=9;
pinMode (LED, OUTPUT);
This code generates digital signal having period of 2000ms, hence the frequency is 0.5Hz.
Then to find the value of resistor and capacitor we use the following RC filter equation,
Here we can choose C = 1uF and f =0.5Hz. Using these values we get R = 318KOhm.
Now we can view the filtered output using oscilloscope. This is shown below.
The output of the RC filter is shown in blue color. This sine wave is not exact because of the filter design but it illustrates the concept of converting digital pulses to sinusoidal signal.