Arduino Starter Series - The Spaceship Hyperdrive

Arduino Aug 17, 2015

This is a project from my Arduino starter series.

In this project I'm going to make a spaceship hyperdrive, well not really but this project is from the Arduino Projects Book and it's an awesome learning experience on the way to Arduino mastery.

My code for this example greatly differs from the example provided in the Arduino Projects Book, I decided to use the Bounce2 library to set the button up easier. It makes life easier when dealing with push buttons.

This project is ideal for beginners who want to grasp the basics of Arduino programming and prototyping. Enjoy!

Project Requirements

Arduino Uno/Duemilanove/Diecimila
USB cable to program Arduino
Three LEDS (Two red and one green)
Three 220 Ohm Resistors
Two 10k Resistors
One Pushbutton
Wires to power the components on the breadboard

The Breadboard Setup

Ensure that your configuration is the same as specified in this image

Arduino Sketch

As usual, I've commented the code as mush as possible to explain every line.

#include <Bounce2.h>

// These are the pins for the red and green LEDS that tell us the hyperdrives state
const int redPin1 = 5;
const int redPin2 = 6;
const int greenPin = 4;

// Set the pin for the button so we can tell the hyperdrive what to do
const int buttonPin = 3;
const int bounceDelay = 5;

// Using the Bounce 2 Library to create a button with debounce functionality
// Read more here:
Bounce hyperButton = Bounce(); // The button will fire up our hyperdrive

void setup() {
  // LED setup
  pinMode(redPin1, OUTPUT);
  pinMode(redPin2, OUTPUT);
  pinMode(greenPin, OUTPUT);
  // Hyper drive button setup

// The loop function
void loop() {
  hyperButton.update(); // The value of the Bounce2 button needs to be updated once per loop before reading the value
  int value =; // We read the value of the button and pass it to a int called value
  if (value == HIGH) {
    hyperLaunch(); // If the value is HIGH then the hyperdrive is engaged
  } else {
    hyperStandby(); // If the value is LOW then the hyperdrive is in standby

// Hyper drive standby function
void hyperStandby() {
  digitalWrite(redPin1, LOW);
  digitalWrite(redPin2, LOW);
  digitalWrite(greenPin, HIGH); // When in standby mode the green LED is on

// Hyperdrive engaged functionality
// Flash the red LEDs in sequence to indicate hyperdrive is engaged
void hyperLaunch() {
  digitalWrite(greenPin, LOW); // The green LED must be disabled here
  digitalWrite(redPin1, HIGH);
  digitalWrite(redPin2, LOW);
  digitalWrite(redPin1, LOW);
  digitalWrite(redPin2, HIGH);

This project is available on my Github page

Nicholas Bester

I have 15 years of experience in design, development and implementation of digital marketing solutions ranging from virtual reality, 3D projection mapping, mobile apps and massive web platforms.