SINE WAVE GENERATION CODE BY ARDUINO UNO SINGLE OR THREE PHASE

Here is sine wave generation code by Arduino UNO single or three phase very easily

/* Design & Deloped By Mr. Adeeb Raza

   TESTED OK By Mr. Adeeb Raza

   Note:- A single radian is just below 57.3 degrees

   Ques. Convert 5/12 π radians into degree measure

   ANS :- 5/12 = 0.416 x 3.142 = 1.309 x 57.3 = 75.01 degrees 

   FYI Radian  (One Radian = 57.3 degrees)

   90 = 1.571 = (pi)/2                        (  90 / 57.3 = 1.570 )

   120 = 2.094                                  ( 120 / 57.3 = 2.094 )

   180 = 1.342 = pi                           ( 180 / 57.3 = 3.141 )

   270 = 4.712 = (pi)*1.5 or 3(pi)/2   ( 270 / 57.3 = 4.712 )

   360 = 6.283 = 2 (pi)                      ( 360 / 57.3 = 6.282 )

   Range is 0 – 6.283

*/

int R = 9;             // Initialize arduino pin no. 9 as output for R Phase

int Y = 8;             // Initialize arduino pin no. 8 as output for Y Phase

int B = 7;             // Initialize arduino pin no. 7 as output for B Phase

void setup() {

 Serial.begin(9600);                // Serial Printer

 pinMode(9, OUTPUT);          // R Phase Output at pin no.11  

 pinMode(8, OUTPUT);          // Y Phase Output at pin no.10

 pinMode(7, OUTPUT);          // B Phase Output at pin no.9

}

  void loop() {

  for(int x=0;x<63;x++) {// Loop is 0 to 62 exit at 63

  float y = float(x)/10;                     //Make range 0 to 6.2

  delay(5);   

  //Serial.println(sin(y));                  // Range is -1 to 1

  Serial.println(sin(y)*2.5);              // Range is -2.5 to 2.5

  //Serial.println(sin(y)* 100);          // Range is -100 to 100

  // Serial.println(sin(y)* 200) ;        // Range is 0 to 200

  // Serial.println(sin(y)* 100) ;        // Range is 20 to 220

  digitalWrite(R, OUTPUT);             // R Phase Output at pin no.11

  delay(6.666);                           // Delay 6.6 milli seconds 120 degree

  digitalWrite(Y, OUTPUT);              // Y Phase Output at pin no.10

  delay(6.666);                           // Delay 6.6 milli seconds 120 degree

  digitalWrite(B, OUTPUT);              // B Phase Output at pin no.9

  delay(6.666);                           // Delay 6.6 milli seconds 120 degree

   }

}

// End Of Code

Clink on link:- http://www.areptone.in/adeebraza/sinewave.pdf

Thanks.

Adeeb Raza

About adeebraza1236

I am an electronic instrumentation engineer by profession but I am working as a design engineer. I can design electronic hardware interface circuits for computer based security system, Computer based industrial control system for automation and process control Etc. My Interests: Electronics Circuit designing with PCB Designing, Computer software development using VB & C , PC based security system, Designing LED Lights, UPS, Inverter Etc
This entry was posted in Adeeb Raza, Allahabad, arduino, Arduino UNO, Areptone, Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s