Outputting pwm at a specific at 100hz

Hi there,

I have an array of pwm value which represent the speeds at which I want a motor to spin.

I want to change the pwm signal at a rate of 100hz, and at the end of the array, loop back round to the start.

Can someone please give me some pointers towards how best to do this. My thoughts were to use the servo library and some sort of timer to change the pwm value every 1/100th of a second?

Any help is greatly appreciated.

Thanks, Henry

Blink without delay?

Thanks! :slight_smile:

Or Timer one library:
https://www.pjrc.com/teensy/td_libs_TimerOne.html

#include <TimerOne.h>
//UNO only

void setup()
{
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);

Timer1.initialize(100);  // Frequency, 100us = 10khz
Timer1.pwm(9,512);       // 50% DC on pin 9

//Timer1.pwm(10,255);    // 25% DC on pin 10

// D.C. 
// 10KHz
// You can use 2 to 1023 
// 0 & 1 gives a constant LOW 
// 1024 gives a constant HIGH
// 2 gives ~125ns HIGH pulses
// 1023 gives ~125ns low pulses
// 512 gives 50us
}

void loop()
{
}