Nibbles and Bits
The Care and Feeding of My Pet Arduino


by Budd Churchward - WB7FHC - NIBBLES AND BITS LIBRARY

'My Dog Has Fleas' - A Binary Music Machine
« 1 2  3  4 5 6 7 8 9 10 11 12 »

Section 3 - Just Messing Around
Just for fun and to give you a chance to try your speaker out. Let's take a moment to play.

You do not need to use a breadboard for this little side trip. Simply hook any one of the two speaker leads to Arduino's pin 11. Hook the other one up to Arduino's ground.

Copy and paste the sketch on the right into a project. Compile it and run it. Mess around with the numbers. You can change anything but the 11's. They are the pin number so they stay the same.

When you have driven yourself crazy enough, pull one or both of the speaker leads and we will go back to work in the next section.

Next Section »

/* GOT FLEAS?
   (c) 2011, Budd Churchward - WB7FHC
   04-09-11

   Hook a mini speaker between pins 11 and ground
   on your Arduino and then run this sketch.
   
   Play around. Change any number but the 11's.
*/

void setup() {
  pinMode(11,OUTPUT);
}

void loop() {
  for (int x=300; x<1500; x=x+100) {
    tone(11,x,40);
    delay(80);
  }
  for (int x=1500; x>300; x=x-100) {
    tone(11,x,40);
    delay(80);
  }
}