Category: Arduino Homework Exercises
Twinkle Twinkle Little Star
Watch my little LED twinkle with the help of three different activators!
Note: Audio not supplied by Arduino board.
Circuits 08, 09, and 13 – Karen Vellensky
Circuit 08 https://vimeo.com/143942398
Circuit 09 https://vimeo.com/143942455
Circuit 13 https://vimeo.com/143942456
Oscar’s Circuits
Hello class,
Here are my circuits completed for homework. Please enjoy.
Thank you for watching.
Jenna’s Circuits 7, 9, and 13
All your circuits are belong to us
Here are the videos of my circuits 8, 9, and 13. They work!
Potentiometers, and photo resistors, and force sensitive resistors, OH MY!
Twist and shine
Glow in the dark
Dim under pressure
Saria Gebeily – REG and SONO
Jenna’s Updated Circuit 6
For my revision to circuit 6, I edited the music and added a little LED flair.
Special shout out to Disney/MiceChat for the sweet it’s a small world character graphics.
The full edited code can be found below:
//Edited Arduino Code 6 – it’s a small world version
int speakerPin = 9;
int LED1 = 10;
int LED2 = 11;
int LED3 = 12;
int length = 36; // the number of notes
char notes[] = “ffafggg ggbgaaa aaCabbbagcef “; // a space represents a rest
int beats[] = { 4, 1, 2, 2, 4, 1, 3, 0, 0, 0, 4, 1, 2, 2, 4, 1, 3, 0, 0, 0, 4, 1, 2, 2, 4, 1, 3, 1, 1, 6, 6, 6, 0, 0 , 0, 0 };
int tempo = 100;
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, 1070, 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);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
}
void loop() {
for (int i = 0; i < length; i++) {
// Turn on LEDs
if (notes[i] == ‘c’ || notes[i] == ‘f’ || notes[i] == ‘b’){
digitalWrite(LED1, HIGH);}
else if (notes[i] ==’d’ || notes[i]==’g’ || notes[i]==’C’) {
digitalWrite(LED2, HIGH);
}
else
digitalWrite(LED3, HIGH);
//Play notes
if (notes[i] == ‘ ‘) {
delay(beats[i] * tempo); // rest
} else {
playNote(notes[i], beats[i] * tempo);
}
digitalWrite(LED1, LOW); //turn LEDS off
digitalWrite(LED2, LOW);
digitalWrite(LED3, LOW);
// pause between notes
delay(tempo / 2);
}
}
** REVISION:
I realized after posting that the part of the code to include rests in between notes is incorrect. In the notes vector, it should only include one space per rest and the length of the rest should be modified by the corresponding number in the beats vector. I tried to edit and reupload, but my piezo speaker lost a leg in the process! 🙁
RGB LED! RGB LED! RGB LED! RGB LED! RGB LED! RGB LED! RGB LED! RGB LED!
Here’s my RGB LED!
The code identified the LEDs incorrectly, so the colors are weird. I’ll identify them correctly later!
Thanks for watching!
-Will-



