Introduction: HKU ITTT SpaceShuttle
In The Netherlands we had a school project called: If This Then That.
We had to make something interactable with an arduino.
In this project i'm gonna explain how to make a space shuttle with led lights, a soundtrack and a hood that can be opened with a servo motor.
Step 1: Arduino Breadboard and Connections
-Arduino: Arduino Uno (Ref 3)
-1 Potmeter
-1 Piezo Buzzer or Speaker
-2 Led lights
-1 Servo Motor
-2 Resistances
-Wires
Step 2: The Coding Part
//Acces the different notes and include the ServoMotor.
#define NOTE_D5 587
#define NOTE_E5 659
#define NOTE_F5 698
#define NOTE_G5 784
#define NOTE_A5 880
#define NOTE_D6 1175
#define NOTE_E6 1319
#define NOTE_F6 1397
#include <Servo.h>
Servo myServo; //make a variable out of the class Servo
int ledState = LOW; // ledState used to set the LED
unsigned long previousMillis = 0; // will store last time LED was updated
const long interval = 1000; //A Const won't change
int speakerPin = 9; //Speaker or Piezo buzzer variable
int potPin = 0; //PotMeter variable
int valuePin0; //Variable for the change in value when turning the potMeter
//Setup Runs only once
void setup()
{
myServo.attach(6); //Add Servo to pin 6
pinMode(7, OUTPUT); //Add led to pin 7
pinMode(8, OUTPUT); //Add led to pin 8
pinMode(speakerPin, OUTPUT); //Add speaker or piezo to variable of the pin
}
//Loop is an update funcion
void loop()
{
valuePin0 = analogRead(potPin); //Read valuepin in analog so it have changeble values
valuePin0 = map(valuePin0, 0, 1023, 0, 89); //Map out the range of the potmeter so it can be used with the servoMotor
ledLights(); //Void ledLights
if(valuePin0 >= 89) //if the value is higher or the same as 89 play the song
{
song();
}
else if(valuePin0 <= 88) // else no speakertone and move servo
{
noTone(speakerPin);
myServo.write(valuePin0);
}
myServo.write(valuePin0); //backup to move the servo
}
//Function to define the beeping sound
void beep (unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds) //code for working out the rate at which each note plays and the frequency.
{
int x;
long delayAmount = (long)(1000000/frequencyInHertz);
long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2));
for (x=0;x
{
digitalWrite(speakerPin,HIGH);
delayMicroseconds(delayAmount);
digitalWrite(speakerPin,LOW);
delayMicroseconds(delayAmount);
}
delay(20);
}
//Function to make the leds blink separted from the other code
void ledLights(){
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval)
{
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else
{
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(7, ledState);
digitalWrite(8, ledState);
}
}
//Zelda: Song Of Storms
void song() //here is where all the notes for the song are played.
{
// beep(Speaker pin, Note, duration in milliseconds)
beep(speakerPin, NOTE_D5, 100);
delay(80);
beep(speakerPin, NOTE_F5, 100);
delay(80);
beep(speakerPin, NOTE_D6, 300);
delay(250);
beep(speakerPin, NOTE_D5, 100);
delay(80);
beep(speakerPin, NOTE_F5, 100);
delay(80);
beep(speakerPin, NOTE_D6, 300);
delay(250);
beep(speakerPin, NOTE_E6, 300);
delay(200);
beep(speakerPin, NOTE_F6, 100);
delay(100);
beep(speakerPin, NOTE_E6, 100);
delay(80);
beep(speakerPin, NOTE_F6, 100);
delay(80);
beep(speakerPin, NOTE_E6, 100);
delay(80);
beep(speakerPin, NOTE_C6, 100);
delay(80);
beep(speakerPin, NOTE_A5, 300);
delay(300);
beep(speakerPin, NOTE_A5, 300);
delay(100);
beep(speakerPin, NOTE_D5, 300);
delay(100);
beep(speakerPin, NOTE_F5, 100);
delay(100);
beep(speakerPin, NOTE_G5, 100);
delay(100);
beep(speakerPin, NOTE_A5, 300);
delay(500);
beep(speakerPin, NOTE_A5, 300);
delay(100);
beep(speakerPin, NOTE_D5, 300);
delay(100);
beep(speakerPin, NOTE_F5, 100);
delay(100);
beep(speakerPin, NOTE_G5, 100);
delay(100);
beep(speakerPin, NOTE_E5, 400);
delay(500);
//Second Segment
beep(speakerPin, NOTE_D5, 100);
delay(80);
beep(speakerPin, NOTE_F5, 100);
delay(80);
beep(speakerPin, NOTE_D6, 300);
delay(250);
beep(speakerPin, NOTE_D5, 100);
delay(80);
beep(speakerPin, NOTE_F5, 100);
delay(80);
beep(speakerPin, NOTE_D6, 300);
delay(250);
beep(speakerPin, NOTE_E6, 300);
delay(200);
beep(speakerPin, NOTE_F6, 100);
delay(100);
beep(speakerPin, NOTE_E6, 100);
delay(80);
beep(speakerPin, NOTE_F6, 100);
delay(80);
beep(speakerPin, NOTE_E6, 100);
delay(80);
beep(speakerPin, NOTE_C6, 100);
delay(80);
beep(speakerPin, NOTE_A5, 300);
delay(300);
beep(speakerPin, NOTE_A5, 300);
delay(100);
beep(speakerPin, NOTE_D5, 300);
delay(100);
beep(speakerPin, NOTE_F5, 150);
delay(100);
beep(speakerPin, NOTE_G5, 150);
delay(100);
beep(speakerPin, NOTE_A5, 300);
delay(200);
beep(speakerPin, NOTE_A5, 400);
delay(100);
beep(speakerPin, NOTE_D5, 600);
delay(100);
}
Step 3: Making the Space Shuttle
1: Go to a sawmill and buy a block of wood. I bought Redwood because it is softer and easier to carve with tools.
2: I used a planing machine to plan the nose of the shuttle and to plan all of the corners.
3: With a pencil i drew a wing on a normal piece of wood to Ensure that the size was correct then i used an automatic saw and i sawed both the Wings of the shuttle.
4: I fixed the Wings to the shuttle with only wooden sticks, this method ensured me to take the Wings of the shuttle when needed.
5: Added another wing on top of the shuttle in the same way as step 3 and 4.
6: With a chisel i carved a hole in the side of the shuttle were the arduino can be placed.
7: I went to a metal workshop, where 2 steel plates were made that fitted the holes. steel plates of 1mm.
8: I fixed the metal plates with piano hinges and carved in the nose another hole with the chisel.
9: Make holes with a screwdriver for the wires
10: Place the arduino with battery in the shuttle and connect the wires with te components.
END