Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] generating 23Khz from arduino

Status
Not open for further replies.

aliyesami

Full Member level 6
Joined
Jan 7, 2010
Messages
369
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
USA
Activity points
4,190
can someone give me the code for generating this frequency from arduino or guide me how to do it ?

thanks
 

Code:
int outPin = 8;                 // digital pin 8

void setup()
{
  pinMode(outPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
  digitalWrite(outPin, HIGH);   // sets the pin on
  delayMicroseconds(44);        // pauses for 44 microseconds      
  digitalWrite(outPin, LOW);    // sets the pin off
  delayMicroseconds(44);        // pauses for 44 microseconds

I hope its help you
 

You mean about the correct delay to use?
I would suggest you try both and check the generated frequency, then you'll see which one is wrong and probably gain some experience which will help you remember the proper period and toggle delay relation for a given frequency.
 

(1/23.000)/2= is your result...

Now select the duty cycle...



The result for this is 0,000.043.478 seconds total or cycles 0,000.021.739 seconds by period... <------- EDITED!!!
 
Last edited:

what do you think about this method of freq generation ?> i found this browsing on web apparently there is a tone() function in Arduino


void setup() {

}

void loop() {
// turn off tone function for pin 8:
noTone(8);
// play a note on pin 6 for 200 ms:
tone(6, 440, 200);
delay(200);

// turn off tone function for pin 6:
noTone(6);
// play a note on pin 7 for 500 ms:
tone(7, 494, 500);
delay(500);

// turn off tone function for pin 7:
noTone(7);
// play a note on pin 8 for 500 ms:
tone(8, 523, 300);
delay(300);
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top