Try changing the value 4 in the line below to lower and higher values.  

int pitch = 200 + reading / 4;
This will expand or restrict the range of frequencies.

 Returning to the first sketch, try and modify it to play a tune. Hint, you can just change the values in the 'tones' array. Note that if you change the number of notes from 10 notes, then you will need to change 'numTones' accordingly.
About the Author

Simon Monk is author of a number of books relating to Open Source Hardware. The following books written by Simon are available from Adafruit: Programming Arduino30 Arduino Projects for the Evil Genius and Programming the Raspberry Pi.

This guide was first published on Dec 12, 2012. It was last updated on Dec 12, 2012.

This page (Other Things to Do) was last updated on Oct 17, 2012.

Text editor powered by tinymce.