generate 10khz signal

how to use Arduino Uno to generate random pseudo signal at 10Khz?

How accurate does the frequency have to be and what is to be random about it ?

Use millis() to do the timing or even the tone() function if a square wave output is acceptable.

UKHeliBob:
How accurate does the frequency have to be and what is to be random about it ?

Use millis() to do the timing or even the tone() function if a square wave output is acceptable.

not has to be that accurate, around 10Khz will be fine. such as 8 k or 11 k, the random is 01010000100010101010101...random high and low. not 010101010101(0 refers low and 1 refers high for square wave)
thanks

Have you got any code that you have tried ?
Something like this comes to mind

start of loop
  if 10 microseconds since previous pulse
    set output pin to random(0,2)
    save time of pulse
  end of if
end of loop

UKHeliBob:
Have you got any code that you have tried ?
Something like this comes to mind

start of loop

if 10 microseconds since previous pulse
    set output pin to random(0,2)
    save time of pulse
  end of if
end of loop

oh , nice thought. i was mess with the TCCRnB, thought that would solve the problem. well. i m really noob in programming, can you explain you pseudo code into real code? really thanks

Have a look at the BlinkWithoutDelay example in the IDE. It blinks an LED on/off every second using millis() as a timer. Change millis() to micros() and you can speed it up considerably.

The preferred way to do what you want may well be to use a hardware timer but a bit of experimentation with this method will show you what is possible. Will there be much else going on in your program ? If so, this method will not work if you use the delay() function anywhere.

I have just come across your other thread on a very similar subject http://forum.arduino.cc/index.php?topic=168638