About
We made a circuit with an LCD screen and a speaker. Then we coded the LCD to say the name of our song, Sandstorm, and the speaker to play each note. In this unit we learned about electricity and coding.
Content
Electricity- the flow of energy between charged electrons
Voltage- potential energy difference through an obstacle with resistance
Current- "flow" of electricity through a circuit
Circuit- a loop of conductive material that connects the negative and positive sides of a power source
Resistance- measure of how much current is slowed
Power- rate at which energy is transferred by a circuit
Voltage- potential energy difference through an obstacle with resistance
Current- "flow" of electricity through a circuit
Circuit- a loop of conductive material that connects the negative and positive sides of a power source
Resistance- measure of how much current is slowed
Power- rate at which energy is transferred by a circuit
Pictures
Reflection
The hardest part of this project was the coding. In order to play the song we wanted we used "pitches.h". This library includes predefined notes. This required a lot of copy pasting but was easier from a musical standpoint. We also struggled to set the LCD screen perfectly every time. It took my a while to understand how put words on the second line as well.
Our Code
/*
Darude - Sandstorm
Speaker on port 8
By Ryan, Andrew, and Diamon
*/
#include "pitches.h"
//Tone Library
#include <LiquidCrystal.h>
//LiquidCrystal Library
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//LCD Pins
int shortTone = 80; //Length of Short Note
int longTone = 200; //Length of Long Note
int standardDelay = 40; //Delay
int delayBetweenBars = 50; //Delay
void setup() {
lcd.begin(16, 2); //Length and Height of LCD Screen
lcd.clear();
}
void loop() {
lcd.clear(); //Clear Screen leftover text onboard RAM
lcd.setCursor(0, 0); //Print on first row
lcd.print("Robot Art Show"); //Print Robot Art Show
delay(3000); //Delay 3 seconds
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Darude Sandstorm");
tone(8, NOTE_B3, shortTone); //Play tone, Pin8, note, length of note
delay(shortTone); //Length of note
noTone(8); //stop tone
delay(standardDelay); //Delay between notes
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, longTone);
delay(longTone);
noTone(8);
delay(delayBetweenBars);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8,NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8,NOTE_E4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_D4, shortTone); //Play tone, Pin8, note, length of note
delay(shortTone); //Length of delay
noTone(8); //Stop tone
delay(standardDelay);
tone(8,NOTE_D4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_D4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_D4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_D4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_D4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_D4, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_A3, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, longTone);
delay(longTone);
noTone(8);
delay(delayBetweenBars);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8,NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, longTone);
delay(longTone);
noTone(8);
delay(delayBetweenBars);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8,NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
}
Darude - Sandstorm
Speaker on port 8
By Ryan, Andrew, and Diamon
*/
#include "pitches.h"
//Tone Library
#include <LiquidCrystal.h>
//LiquidCrystal Library
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//LCD Pins
int shortTone = 80; //Length of Short Note
int longTone = 200; //Length of Long Note
int standardDelay = 40; //Delay
int delayBetweenBars = 50; //Delay
void setup() {
lcd.begin(16, 2); //Length and Height of LCD Screen
lcd.clear();
}
void loop() {
lcd.clear(); //Clear Screen leftover text onboard RAM
lcd.setCursor(0, 0); //Print on first row
lcd.print("Robot Art Show"); //Print Robot Art Show
delay(3000); //Delay 3 seconds
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Darude Sandstorm");
tone(8, NOTE_B3, shortTone); //Play tone, Pin8, note, length of note
delay(shortTone); //Length of note
noTone(8); //stop tone
delay(standardDelay); //Delay between notes
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, longTone);
delay(longTone);
noTone(8);
delay(delayBetweenBars);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8,NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8,NOTE_E4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_D4, shortTone); //Play tone, Pin8, note, length of note
delay(shortTone); //Length of delay
noTone(8); //Stop tone
delay(standardDelay);
tone(8,NOTE_D4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_D4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_D4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_D4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_D4, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_D4, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_A3, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, longTone);
delay(longTone);
noTone(8);
delay(delayBetweenBars);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8,NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, longTone);
delay(longTone);
noTone(8);
delay(delayBetweenBars);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8,NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, shortTone);
delay(shortTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_B3, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
tone(8, NOTE_E4, longTone);
delay(longTone);
noTone(8);
delay(standardDelay);
}