frequency range for Arduino

Can someone help me with this? I am a complete beginner, but would like to build a light machine with a strobe effect. I have specific frequencies I need - ranging from 20Hz to 20KHz.
ie Hz -20,40, 60, 100, 200, 500, 750. KHz - 1, 5, 10, 20 . is this possible with Arduino? and how would I go about it?

You'll have to explain what "a light machine" is

If what you are looking to do is strobe a light (presumable some sort of LED) at particular frequencies, then the Arduino can do that. Do you also want to control the ratio of on-time to off-time?

the light machine I am interested in building is for health and combines a cluster of different Wavelength LEDs around a cold laser in the middle. these are often used in osteopathy and general health. The different speeds of the strobe effect are helpful for healing different conditions.
I had bought one of these machines and the company then folded so I unable to get it repaired. so I am looking in to how to build them. Also I wish to make a probe which is the same thing but with just the cold laser and no LEDs.

The time on and off I think is equal. What I am really look for is if the different frequencies mention are possible to program in, and if they are attainable especially the higher ones ie 10 and 20 Khz

Yes, they are easy to generate using the one of the on-chip timers. This is the code I use to generate a variable frequency from pin 9 on a Uno:

const int ocr1aPin = 9;

// Set the frequency that we will get on pin OCR1A
void setFrequency(uint16_t freq)
{
  uint32_t requiredDivisor = (F_CPU/2)/(uint32_t)freq;
  uint16_t prescalerVal;
  uint8_t prescalerBits;
  if (requiredDivisor < 65536UL)
  {
    prescalerVal = 1;
    prescalerBits = 1;
  }
  else if (requiredDivisor < 8 * 65536UL)
  {
    prescalerVal = 8;
    prescalerBits = 2;
  }
  else if (requiredDivisor < 64 * 65536UL)
  {
    prescalerVal = 64;
    prescalerBits = 3;
  }
  else if (requiredDivisor < 256 * 65536UL)
  {
    prescalerVal = 256;
    prescalerBits = 4;
  }
  else
  {
    prescalerVal = 1024;
    prescalerBits = 5;
  }

  uint16_t top = ((requiredDivisor + (prescalerVal/2))/prescalerVal) - 1;
  TCCR1A = 0;
  TCCR1B = (1 << WGM12) | prescalerBits;
  TCCR1C = 0;
  OCR1A = (top & 0xFF);
}

// Turn the frequency on
void on()
{
  TCNT1H = 0;
  TCNT1L = 0;  
  TCCR1A |= (1 << COM1A0);
}

// Turn the frequency off and turn of the IR LED
void off()
{
  TCCR1A &= ~(1 << COM1A0);
}

void setup()
{
  digitalWrite(ocr1aPin, LOW);
  pinMode(ocr1aPin, OUTPUT);
}

Thank you so much.
As I had said I am a complete novice.
are 8, 16, 32, 64, the frequencies?
and do they represent number of flashes per second?

Realising you're a noob, what do you expect to do with a light flashing at up to 20kHz?
(Bearing in mind most people can't see stuff beyond about 70Hz, unless it is moving)

people are not looking at it, it is shinning into the body, it has an effect on the bodies inteligence,

lotusmoon:
Thank you so much.
As I had said I am a complete novice.
are 8, 16, 32, 64, the frequencies?
and do they represent number of flashes per second?

No, to set the frequency (= number of flashes per second) you call setFrequency, passing the required frequency. For example:

set Frequency(20000);

would set the frequency to 20kHz.

it has an effect on the bodies inteligence,

OK

Thank you again
I will now spend time researching all of this, as this is the first day I have started.
I do not know about programming or electrics so it may take a bit of time.
Is there a specific Arduine I should buy for this project?

lotusmoon:
Thank you so much.
As I had said I am a complete novice.
are 8, 16, 32, 64, the frequencies?
and do they represent number of flashes per second?

Hz is frequency = Cycles per second. The period (which you will be programming) is the time for one complete on/off cycle.

100Hz would have a period of 1/100th of a second, or 10 milliseconds. To generate a 100Hz square wave, you would turn the LED on for 5mS, off for 5mS, and repeat...

In order to get into the kHz range, you'll have to use the microsecond functions. Since you won't be able to see the flashing at high frequencies and you (porbably) don't have access to an oscilloscope, you'll just have to trust that if works at visable flash-rates, it's working at higher rates. (You should notice that the LED is dimmer than full-on when it's flashing at higher rates, since it's on half the time, and off half the time.)

...and the company then folded so I unable to get it repaired.

That seems to happen to just about every company that sells "healing machines". :smiley: :smiley: :smiley:

is there a specific place i should place the frequency in the code ie "set Frequency(20000);"

If you are looking to generate a fixed frequency, you can put it at the end of setup(). If you are looking to select the frequency depending on some input device, then you need to put it after you have read the input device and determined what frequency to use.

After setting the frequency, you need to call on() to start generating pulses.

lotusmoon:
people are not looking at it, it is shinning into the body, it has an effect on the bodies inteligence,

You do know that this is absoloute rubbish don't you?
There is no measurable medical effect from this it is all placebo.
We normally do not encourage the tin foil hat brigade here.

And here I was going to ask if crystals and magnets would be involved.

Thank you dc42
there are many frequencies that effect different things ie 75HZ is normally good for the lymph 750Hz good for tendonitis, 1KHz is good for bones.
so I wanted to have about 10 different frequencies, which I could easily select, As i many use many different one in a session.

As for you other guys thank you for your invaluable information, I will bare it all in mind. I had only described what the machine was for as I was asked. But I will get back to you on if it is medically proven, I would guess it is not though.

Please. Links to such medical information?

I could use such help with arthritis and my doctor has yet to recommend light therapy.

Have you given any thought to how you are going to test that this is doing what you think it should?
Do you have a scope?