I have been playing around with the Arduino for a couple of months. The Arduino is an inexpensive open-source electronics prototyping platform (http://www.arduino.cc/. The compilation below represents a very simple project to connect an amplified speaker to the Arduino.
The amplifier I used for this project is an LM386. The LM386 is a power amplifier designed for use in low voltage applications. It ant the other parts needed for this project , capacitors, resistors and a speaker, can be purchased at Radio Shack.
This example makes use of a Sound Hello World sketch by David Fowler to generate tones.
This also represents my first attempt at a circuit schematic using the freeware version of Eagle from CadSoft at http://www.cadsoft.de/.
My hope is that someone will find this useful and will be able to follow what I have done as I have done following the examples posted by others.
//Arduino Sound Hello World
//Created by David Fowler of uCHobby.com
//Define the I/O pin we will use for our sound output
#define SOUNDOUT_PIN 9
void setup(void){
//Set the sound out pin to output mode
pinMode(SOUNDOUT_PIN,OUTPUT);
}
void loop(void){
//Generate sound by toggling the I/O pin High and Low
//Generate a 1KHz tone. set the pin high for 500uS then
//low for 500uS to make the period 1ms or 1KHz.
//Set the pin high and delay for 1/2 a cycle of 1KHz, 500uS.
digitalWrite(SOUNDOUT_PIN,HIGH);
delayMicroseconds(500);
//Set the pin low and delay for 1/2 a cycle of 1KHz, 500uS.
digitalWrite(SOUNDOUT_PIN,LOW);
delayMicroseconds(500);
}
No comments:
Post a Comment