title: How to generate a square wave using C#?
body: <p>I would like to generate a digital signal, which'll then be used to implement an ASK(Amplitude Shift Keying) Signal.</p>
  
  <p>Let's say the message bits are 10110, data rate : 3.9 Khz &amp; amplitude A.</p>
  
  <p>What would be the best way to generate a Square signal(Digital).</p>
  
  <p>I tried the following code, but the outcome is not a desired one.</p>
  
  <pre><code>double[] x = new double[1000];
  double[] y = new double[1000];
  double freq = 3900.0;
  
  for (int k = 0; k &lt; y.Length; k++)
  {
      x[k] = k;
      y[k] = (4 / Math.PI) * (((Math.Sin(((2 * k) - 1) * (2 * Math.PI * freq))) /   ((2 * k) - 1)));
  }
  
  // Plot Square Wave
  plotSquare(x, y, Msg);
  </code></pre>