Hello everyone ;
im new in programing , in my project i want to generate a pwm signal using a fixed frequency and various duty cycles stored in an array ; the code below works perfectly for what i need but i want it to be more precise using timer interrupt and get rid of the function delay() what is the easiest way to do that ? im using arduino mega (atmega2560)
const int pinV1 = 6;
contst int V1 = {168,168,168,167,171,174,178,189 ,102};
void setup ()
{
Serial.begin (9600);
pinMode(pinV1, OUTPUT);
}
void loop ()
{
int arrLen = sizeof(V1) / sizeof(LEAD1[0]);
for (int t=0; t<arrLen; t++){
analogWrite(pinV1, V1[t]);
delay(2);
}
}