One of the great things about going to an awesome school is the teachers, especially those who will let you borrow microprocessors.
I’ve been wondering for several months now if I should buy an Arduino, the relatively low cost microcontroller that has hobby engineers going wild (seriously, wild. You would not believe how much someone can love a computer chip until you’ve seen the die hard Arduino fans). Fortunately, my school’s ASR (Applied Science Research) teacher let me borrow an Arduino for the weekend. I’ve only had a couple hours to tinker with it, but so far I’ve been very impressed by both the Atmega 328 (the chip) and the design of the board. I’ve had the chance to sift through some of the documentation on the Arduino site, and my favorite tutorial so far has been the Melody tutorial.
Setup was quick and easy, once you get the hang on which pins do what, and yielded a pretty annoying little song (but still pretty cool).
I’ve gotten a lot of feedback that there should be more videos on BW Science Labs, so here’s one I shot of my borrowed Arduino playing “Marry Had a Little Lamb”.
I only recorded this once, even though it plays in a loop. After about two or three times of playing “Marry Had a Little Lamb” you start to lose your mind.
And for those of you too lazy to click on the link above, here’s the code I used to make this happen:
int speakerPin = 9;
int length = 15; // the number of notes
char notes[] = “ccggaagffeeddc “; // a space represents a rest
int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 };
int tempo = 300;
void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tone);
digitalWrite(speakerPin, LOW);
delayMicroseconds(tone);
}
}
void playNote(char note, int duration) {
char names[] = { ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘a’, ‘b’, ‘C’ };
int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };
// play the tone corresponding to the note name
for (int i = 0; i < 8; i++) {
if (names[i] == note) {
playTone(tones[i], duration);
}
}
}
void setup() {
pinMode(speakerPin, OUTPUT);
}
void loop() {
for (int i = 0; i < length; i++) {
if (notes[i] == ‘ ‘) {
delay(beats[i] * tempo); // rest
} else {
playNote(notes[i], beats[i] * tempo);
}
// pause between notes
delay(tempo / 2);
}
}
speed up computer says:
February 11th, 2010 at 8:39 pm
Thanks for spending the time to describe the terminlogy to the newbies!
why computer running slow says:
February 12th, 2010 at 8:51 pm
Thanks for sharing this great submit, i really adore your blog, but i’ve some issue i dont know whether it’s my side issue or in your website? some words from the submit in your weblog have charactor encoding problem, yes i use auto detecting, can u pls look into this issue a bit?
Brennon says:
February 12th, 2010 at 11:20 pm
sure, I’ll contact my web devs, could you please email me at brennonw at bwsciencelabs.com describing your errors and how they’re triggered?
that would be hugely helpful. Thanks!
computer speed increase says:
February 13th, 2010 at 6:12 pm
You’re soooo gifted in writing. God is really utilizing you in tremendous methods. You are doing a excellent job! This was an awesome weblog!
Guy Klauser says:
April 24th, 2010 at 3:42 pm
Thanks dude, I never knew this, much appreciated.
Vicente Manely says:
April 30th, 2010 at 12:39 pm
Bless you for finding the time to create this. I value where you are coming from on this article then again I do think that you have more beneficial options.
Anton Pap says:
May 4th, 2010 at 2:47 pm
It appears that you have put a great deal of work into your site and I want more of these on the internet right now. I seriously got a kick through your post. I can’t really have much to convey reacting, I just planned to remark to your impressive work.
trademarking says:
May 17th, 2010 at 7:19 am
Considerably, the blog post is actually the greatest on this worthy topic. I concur with your decisions and will thirstily look forward to see your approaching updates. Saying thanks will not just be adequate, for the phenomenal lucidity in your writing. I will at once grab your feeds to stay informed of any updates. Delightful work and much success in your business endeavors! Have a nice day