Using Arduino UNO to generate sine signal | applied electronics engineering

Using Arduino UNO to generate sine signal

By Applied Electronics - Wednesday, April 5, 2017 No Comments
In this tutorial you will learn how to generate sine signal using Arduino UNO. This tutorial is taken from the site eestuffs.com - Create sine signal from digital pulses using Arduino.

The technique is in fact quite simple. The main idea behind this trick is to convert digital pulses to sine signal by applying the digital pulses to a low pass filter. The sine signal is not an exact sine signal but it is quite close. With better filter one can get better signal.

Using Arduino UNO to generate sine signal Program Code

The frequency of the sinusoidal signal is that of the digital pulse. As you perhaps know you can create digital pulses quite easily with Arduino. The following code generates digital signal at digital pin 9.

const int LED=9;
void setup()
{
pinMode (LED, OUTPUT);
}
void loop()
{
digitalWrite(LED, HIGH);
delay(1000);
digitalWrite(LED, LOW);
delay(1000);
}

Since the delay between the on and off state is 1000ms the total period is 2000ms and therefore the frequency is 0.5Hz.

Using Arduino UNO to generate sine signal Circuit Diagram

Now using resistor and capacitor we can create a Low Pass filter at this frequency. The LPF is then connected to the digital pin 9. This is as shown below.

The value of the resistor and capacitor is easily determined using the RC LPF calculator. The formula is as under:

With f = 0.5Hz and selecting C as 1uF we get R of 318K. In reality we might not have 318KOhm resistor and we select the closest available resistor or use multiple resistor in series to get to 318KOhm.

The output of the LPF is shown via simulation below.

For more arduino tutorials see Getting Started with Arduino, 2nd Edition PDF free download