#include 7;int INPUT1 = 9;int INPUT2 =

#include //—LIBRARY FILE FOR CONNECTING BLUETOOTH MODULE—////——-DEFINING THE TRANSMITTER AND RECEIVER PINS OF BLUETOOTH MODULE—//SoftwareSerial BT(12,13);int ENABLE1 = 5;int ENABLE2 = 6;int ENABLE3 = 7;int INPUT1 = 9;int INPUT2 = 10;int INPUT3 = 11;//———DEFINING THE SINE WAVE—–// int pwmSin = {    0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,    0xbff, 0xc5a, 0xcb2, 0xd08, 0xd59, 0xda7, 0xdf1, 0xe36, 0xe77, 0xeb4,    0xeec, 0xf1f, 0xf4d, 0xf77, 0xf9a, 0xfb9, 0xfd2, 0xfe5, 0xff3, 0xffc,    0xfff, 0xffc, 0xff3, 0xfe5, 0xfd2, 0xfb9, 0xf9a, 0xf77, 0xf4d, 0xf1f,    0xeec, 0xeb4, 0xe77, 0xe36, 0xdf1, 0xda7, 0xd59, 0xd08, 0xcb2, 0xc5a,    0xbff, 0xba1, 0xb40, 0xadd, 0xa78, 0xa11, 0x9a9, 0x93f, 0x8d5, 0x86a,    0x7ff, 0x794, 0x729, 0x6bf, 0x655, 0x5ed, 0x586, 0x521, 0x4be, 0x45d,    0x3ff, 0x3a4, 0x34c, 0x2f6, 0x2a5, 0x257, 0x20d, 0x1c8, 0x187, 0x14a,    0x112, 0xdf, 0xb1, 0x87, 0x64, 0x45, 0x2c, 0x19, 0xb, 0x2,    0x0, 0x2, 0xb, 0x19, 0x2c, 0x45, 0x64, 0x87, 0xb1, 0xdf,    0x112, 0x14a, 0x187, 0x1c8, 0x20d, 0x257, 0x2a5, 0x2f6, 0x34c, 0x3a4,    0x3ff, 0x45d, 0x4be, 0x521, 0x586, 0x5ed, 0x655, 0x6bf, 0x729, 0x794};int instanceA;int instanceB;int instanceC;int sineSize;int inc = 0;int old1,old2,c,d,x;//////////////////////////////////////////////////////////////////////////////void setup() {  BT.begin(9600);  Serial.begin(9600);//——TO MAKE THE PWM OUTPUTS OF PIN 9,10,11 AS 32KHZ CONSTANT FREQUENCY—–///   setPwmFrequency(INPUT1);   setPwmFrequency(INPUT2);  setPwmFrequency(INPUT3);//——DEFINING THE PINS 9,10,11 SHOULD WORK AS OUTPUTS—//  pinMode(INPUT1, OUTPUT);   pinMode(INPUT2, OUTPUT);   pinMode(INPUT3, OUTPUT); //——DEFINING THE PINS 5,6,7 SHOULD WORK AS OUTPUTS—//  pinMode(ENABLE1, OUTPUT);   pinMode(ENABLE2, OUTPUT);   pinMode(ENABLE3, OUTPUT); //——MAKING ENABLE PINS 5,6,7 IN HIGH STATE—–//  digitalWrite(ENABLE1, HIGH);  digitalWrite(ENABLE2, HIGH);  digitalWrite(ENABLE3, HIGH);  //——–TO FIND THE PHASE SHIFT OF THE WAVE———–//  int s = sizeof(pwmSin);  sineSize = s/sizeof(int);  int phaseShift = sineSize / 3;          instanceA = 0;  instanceB = instanceA + phaseShift;  instanceC = instanceB + phaseShift;  sineSize–; }//////////////////////////////////////////////////////////////////////////////void loop() {//—–THESE STATEMENTS WILL MODULATE THE 32KHZ FREQUENCY SIGNALS FROM ARDUINO AND THE INSTANCE VALUES OF SINE WAVE DIFINED PREVIOUSLY—-//  analogWrite(INPUT1, pwmSininstanceA);  analogWrite(INPUT2, pwmSininstanceB);  analogWrite(INPUT3, pwmSininstanceC);  //———TO SEE THE MODULATED OUTPUT OF SINE WAVE AND PWM WAVE—–//Serial.print(analogRead(A0));Serial.print(” “);Serial.println(analogRead(A1));Serial.print(” “);Serial.println(analogRead(A2));//——TO INCREMENT THE NEXT INSTANCE OF SINE WAVE—//  instanceA = instanceA + inc;  instanceB = instanceB + inc;  instanceC = instanceC + inc;   if(instanceA > sineSize)   {  instanceA = 0;  }  if(instanceA < 0)   {  instanceA = sineSize;  }  if(instanceB > sineSize)  {  instanceB = 0;  }  if(instanceB < 0)   {    instanceB = sineSize;  }  if(instanceC > sineSize)  {    instanceC = 0;  }  if(instanceC < 0)  {    instanceC = sineSize;   }//--------READING THE VALUES FROM BLUETOOTH MODULE----//x=BT.read();if(x<=252&&x>-1){    d = x;     Serial.println(d);   Serial.println(“d”);  old2=d;  Serial.println(old2);  delay(1000);}else if (x==253||x==254){  c = x;  Serial.println(c);  Serial.println(“c”);  old1=c;  delay(1000);} else if(x==-1){   Serial.println(“in to else if -1”);      Serial.println(old1);  Serial.println(old2);  if(old1!=0||old2!=0){  c=old1;  d=old2;   Serial.println(old1);  Serial.println(old2);  delay(1000);  }  else{    c=0;    d=0;    delay(1000);  }  }if (c == 253){  inc=1;  Serial.println(2000-d*7);  delay(2000-d*7);  }else if(c==254){  inc=-1;  Serial.println(2000-d*7);  delay(2000-d*7);}  }void setPwmFrequency(int pin) {  if( pin == 9 || pin == 10)   {      TCCR1B = TCCR1B & 0b11111000 | 0x01;    }   else if(pin == 3 || pin == 11)   {    TCCR2B = TCCR2B & 0b11111000 | 0x01;  }}

x

Hi!
I'm Ethel!

Would you like to get a custom essay? How about receiving a customized one?

Check it out