The Midnight Band

For this week’s project, Nick and I decided to create a cover for one of our favourite songs, “Shooting Stars” by the prominent Disco/Tech group Bag Raiders. Our project was divided into two parts, the beat (using Servos) and the melody (using Tone).

In total, we had three percussion-like instruments. The first, being a cork attached to a wooden stick, banging on a piece of wood, functioned as the underlying drum that would provide the 1/4 beat. Next, we had two metal rods attached to two different Servos hit glass cups to create clinking sounds that would harmonise with the Tone produced by the buzzers.

Our Tone had 4 buttons, namely four sounds (E-flat, E,B,A-flat). Each button would make the sound designated for 300 milliseconds, and with code we just had to make sure that we were using F-sharp, for example, the different name of A-flat since those weren’t registered in the library.

So below is the result of what we have created, since midnight yesterday when we first joined forces. Hence the name “Midnight Band”. Enjoy!

// Include the Servo library 
#include <Servo.h> 

Servo myServo1;
Servo myServo2;
Servo myServo3;
int pos1 = 0;  //variable for number of degrees for servo1
int pos2 = 0; //variable for number of degrees for servo2
int pos3 = 0; //variable for number of degrees for servo3
int buttonPin = 2; //activating pin 2 for Push Button 
int buttonPin2 = 4; // activating pin 4 
int buttonPin3 = 7;
int buttonState = 0; //variable for Push Button
int buttonState2 = 0;
int buttonState3 = 0;
int angle = 0;

void loop() { 
buttonState = digitalRead(buttonPin); //reading buttonPin and storing it as buttonState.
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
//Serial.println(buttonState, buttonState2,buttonState3); //telling computer to print buttonState. 
if (buttonState == LOW){ //if button is pressed...
  myServo2.write(180); //setting servo2 to 180 degrees
  delay(500); //wait one second   
   //setting servo1 to 180 degrees
  myServo2.write(20); //setting servo2 to 20 degrees
  delay(500); //wait one second
if (buttonState2 == LOW){
 if(buttonState3 == LOW){
  for(angle = 0; angle<180;angle+=6){
    delay(15);//setting servo1 to 20 degrees

void setup() {
  // attach the servo to pin number 9
  Serial.begin(9600); //activating Serial Monitor
  myServo1.attach(9); //activating pin 9 for servo1
  myServo2.attach(11); //activating pin 11 for servo2
  myServo3.attach(10); //
  pinMode(buttonPin , INPUT); //setting Push Button as an input
  pinMode(buttonPin2 , INPUT);



Leave a Reply