## 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 