static const unsigned int lookup[] {
180,183,186,189,193,196,199,202,
205,208,211,214,217,220,224,227,
230,233,236,239,242,245,247,250,
253,256,259,262,265,267,270,273,
275,278,281,283,286,288,291,293,
296,298,300,303,305,307,309,312,
314,316,318,320,322,324,326,327,
329,331,333,334,336,337,339,340,
342,343,344,346,347,348,349,350,
351,352,353,354,355,355,356,357,
357,358,358,359,359,359,360,360,
360,360,360,360,360,360,360,359,
359,359,358,358,357,357,356,355,
355,354,353,352,351,350,349,348,
347,346,344,343,342,340,339,337,
336,334,333,331,329,327,326,324,
322,320,318,316,314,312,309,307,
305,303,300,298,296,293,291,288,
286,283,281,278,275,273,270,267,
265,262,259,256,253,250,247,245,
242,239,236,233,230,227,224,220,
217,214,211,208,205,202,199,196,
193,189,186,183,180,177,174,171,
167,164,161,158,155,152,149,146,
143,140,136,133,130,127,124,121,
118,115,113,110,107,104,101,98,
95,93,90,87,85,82,79,77,
74,72,69,67,64,62,60,57,
55,53,51,48,46,44,42,40,
38,36,34,33,31,29,27,26,
24,23,21,20,18,17,16,14,
13,12,11,10,9,8,7,6,
5,5,4,3,3,2,2,1,
1,1,0,0,0,0,0,0,
0,0,0,1,1,1,2,2,
3,3,4,5,5,6,7,8,
9,10,11,12,13,14,16,17,
18,20,21,23,24,26,27,29,
31,33,34,36,38,40,42,44,
46,48,51,53,55,57,60,62,
64,67,69,72,74,77,79,82,
85,87,90,93,95,98,101,104,
107,110,113,115,118,121,124,127,
130,133,136,140,143,146,149,152,
155,158,161,164,167,171,174,177,
};
void setup() {
// put your setup code here, to run once:
pinMode (8,OUTPUT);
int x;
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
for (int x=0; x<=360; x++) {
Serial.println(x);
analogWrite(8,lookup[x]);
}
}
this is code ive written quick to try and turn my PWM pin 8 to a sine wave. im using a low pass filter after it to see but this is not close at all :(.
i dont know if im accessing the array right